class GstPython < Formula desc "Python overrides for gobject-introspection-based pygst bindings" homepage "https://gstreamer.freedesktop.org/modules/gst-python.html" url "https://gstreamer.freedesktop.org/src/gst-python/gst-python-1.8.2.tar.xz" sha256 "4f5015239482014c16f435559a45e6c87930340b65ee04e2e6fa164c8d724d97" bottle do sha256 "3b29e268d89ab041806ed98e3459840ee13097865e18655961fe42e102108cf1" => :el_capitan sha256 "789ac75cb0fef84cb334a2ae1185b9f8a5d7fdc83f6137da9bd0080ba82d3abe" => :yosemite sha256 "0a8daf89bcb8ce4f492c8754f0df629cce80514dfd455050f6830cb9ebdca03e" => :mavericks end option "without-python", "Build without python 2 support" depends_on :python3 => :optional depends_on "gst-plugins-base" if build.with? "python" depends_on "pygobject3" end if build.with? "python3" depends_on "pygobject3" => "with-python3" end link_overwrite "lib/python2.7/site-packages/gi/overrides" def install if build.with?("python") && build.with?("python3") # Upstream does not support having both Python2 and Python3 versions # of the plugin installed because apparently you can load only one # per process, so GStreamer does not know which to load. odie "Options --with-python and --with-python3 are mutually exclusive." end Language::Python.each_python(build) do |python, version| # pygi-overrides-dir switch ensures files don't break out of sandbox. system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--with-pygi-overrides-dir=#{lib}/python#{version}/site-packages/gi/overrides", "PYTHON=#{python}" system "make", "install" end end test do system "#{Formula["gstreamer"].opt_bin}/gst-inspect-1.0", "python" Language::Python.each_python(build) do |python, _version| # Without gst-python raises "TypeError: object() takes no parameters" system python, "-c", <<-EOS.undent import gi gi.require_version('Gst', '1.0') from gi.repository import Gst print (Gst.Fraction(num=3, denom=5)) EOS end end end