Skip to content
Permalink
Browse files

gst-python: remove Python 2 support.

Requires pygobject3 with-python@2 option.

See #13133 and #31510.

Closes #35353.

Signed-off-by: FX Coudert <fxcoudert@gmail.com>
  • Loading branch information...
MikeMcQuaid authored and fxcoudert committed Dec 23, 2018
1 parent b73bef1 commit 4ffd6c1dca41706e38a60df42662780db613f864
Showing with 18 additions and 34 deletions.
  1. +18 −34 Formula/gst-python.rb
@@ -3,53 +3,37 @@ class GstPython < Formula
homepage "https://gstreamer.freedesktop.org/modules/gst-python.html"
url "https://gstreamer.freedesktop.org/src/gst-python/gst-python-1.14.4.tar.xz"
sha256 "d0fdb24f93b6d889f309d2f526b8ea9577e0084ff0a62b4623ef1aed52e85a1b"
revision 1

bottle do
sha256 "4412a3a8077e55aa5b1899ff7a89d726afad1f2142e61e93f91d9d54a0b87fe5" => :mojave
sha256 "4fe5e40b6897c575602ff3d668bf9408fde1f9fcfea855fcf08067d06401f5ad" => :high_sierra
sha256 "c6aa1db5ddb24672448b36d1cbf979cfc826fe57b382015bf35b5a5da646c506" => :sierra
end

option "without-python", "Build without python 3 support"
option "with-python@2", "Build with python 2 support"

depends_on "gst-plugins-base"
depends_on "python" => :recommended
depends_on "pygobject3" if build.with? "python"
depends_on "python@2" => :optional
depends_on "pygobject3" => "with-python@2" if build.with? "python@2"

link_overwrite "lib/python2.7/site-packages/gi/overrides"
depends_on "pygobject3"
depends_on "python"

def install
if build.with?("python") && build.with?("python@2")
# 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 "You must pass both --without-python and --with-python@2 for python 2 support"
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
python_version = Language::Python.major_minor_version("python3")
# 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#{python_version}/site-packages/gi/overrides",
"PYTHON=python3"
system "make", "install"
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
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
print (Gst.Fraction(num=3, denom=5))
EOS
end
# Without gst-python raises "TypeError: object() takes no parameters"
system "python3", "-c", <<~EOS
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
print (Gst.Fraction(num=3, denom=5))
EOS
end
end

0 comments on commit 4ffd6c1

Please sign in to comment.
You can’t perform that action at this time.