homebrew-core/Formula/gst-python.rb
2016-11-18 04:39:40 -08:00

58 lines
2.2 KiB
Ruby

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.10.1.tar.xz"
sha256 "5305b34af74a182fd72de0e6093eb6f206ea4d26dad53d0f564603063e80b013"
bottle do
sha256 "5ae84a19d583b1541f096630a0787b430099df9217b2f929144009dcfd5062e2" => :sierra
sha256 "09c9ed5882b2f4ca1f28cadcbc221afb1f3b1b66e739584b0380fe24d2008661" => :el_capitan
sha256 "d2866a9a8a8bc7a2ca8e2e96dd379cd516e3f663ffce8d4808a91297abe6453b" => :yosemite
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