Skip to content

Commit

Permalink
gst-python: remove Python 2 support.
Browse files Browse the repository at this point in the history
Requires pygobject3 with-python@2 option.

See #13133 and #31510.

Closes #35353.

Signed-off-by: FX Coudert <[email protected]>
  • Loading branch information
MikeMcQuaid authored and fxcoudert committed Dec 23, 2018
1 parent b73bef1 commit 4ffd6c1
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions Formula/gst-python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.