[pitivi] Make sure to use our own build of gst-python when inside flatpak



commit 7e2708bdc13b3cc8bc93674f0658722a5396bed6
Author: Thibault Saunier <tsaunier gnome org>
Date:   Sat Jul 15 00:03:33 2017 -0400

    Make sure to use our own build of gst-python when inside flatpak
    
    This allows us to use the now registered GStreamer fundamental
    types.
    
    Differential Revision: https://phabricator.freedesktop.org/D1778

 bin/pitivi.in     |   14 ++++++++++++++
 tests/__init__.py |   10 ++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/bin/pitivi.in b/bin/pitivi.in
old mode 100755
new mode 100644
index 1dd1eb8..e8b35b7
--- a/bin/pitivi.in
+++ b/bin/pitivi.in
@@ -58,6 +58,20 @@ def _in_devel():
 
 
 def _add_pitivi_path():
+    try:
+        import gi.overrides
+    except ImportError:
+        print(_("Could not import 'gi'. "
+                "Make sure you have pygobject available."))
+        exit(1)
+
+    # Let Gst overrides from our prefix take precedence over any
+    # other, making sure they are used. This allows us to ensure that
+    # Gst overrides from gst-python are used when within flatpak
+    local_overrides = os.path.join(LIBDIR, "python" + sys.version[:3],
+                                   "site-packages", "gi", "overrides")
+    gi.overrides.__path__.insert(0, local_overrides)
+
     dir = os.path.dirname(os.path.abspath(__file__))
     if _in_devel():
         root = os.path.split(dir)[0]
diff --git a/tests/__init__.py b/tests/__init__.py
index 07e40b0..3cfbf1d 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -8,6 +8,8 @@ import sys
 import unittest
 from tempfile import mkdtemp
 
+import gi.overrides
+
 
 def get_pitivi_dir():
     """Gets the pitivi root directory."""
@@ -42,6 +44,14 @@ def setup():
 
     from pitivi import configure
 
+    # Let Gst overrides from our prefix take precedence over any
+    # other, making sure they are used. This allows us to ensure that
+    # Gst overrides from gst-python are used when within flatpak
+    local_overrides = os.path.join(configure.LIBDIR,
+                                   "python" + sys.version[:3],
+                                   "site-packages", "gi", "overrides")
+    gi.overrides.__path__.insert(0, local_overrides)
+
     # Make available the compiled C code.
     sys.path.append(configure.BUILDDIR)
     subproject_paths = os.path.join(configure.BUILDDIR, "subprojects", "gst-transcoder")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]