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.12.1.tar.xz" sha256 "1721be4f201eb0a73075dd7d39bf2251798124cb948440d4cf4f02d6fa0078a1" bottle do sha256 "8cd3bd76c3974f299d14d99da614272233924d7bdc7164ce1a27f7c3850e567c" => :sierra sha256 "e0797e6d0742f6efe766000b14ff5131bde5c622f3fceb6389c5bca6d7024baa" => :el_capitan sha256 "1ecd6208b5a378fa1e63713dcbffbb2680cc01917a3ae347597627c58c5b7987" => :yosemite end option "without-python", "Build without python 2 support" depends_on :python3 => :optional depends_on "gst-plugins-base" depends_on "pygobject3" if build.with? "python" depends_on "pygobject3" => "with-python3" if build.with? "python3" 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