summaryrefslogtreecommitdiff
path: root/gst-env.py
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2021-10-14 17:01:01 -0300
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-10-15 20:51:41 +0000
commit1babccfe503de346dfd9722348e2acead742b70a (patch)
treea773950d80c8024711180cad4fdae89f1035e5ed /gst-env.py
parentba79339d56299094d2aab12873e360d55c119b41 (diff)
downloadgstreamer-1babccfe503de346dfd9722348e2acead742b70a.tar.gz
python: Fix using overrides when not building PyGObject
Since 547570cd790f2b2e390edc1dfb5df4c7a33de45c we do not always build PyGObject and our development environment is broken when trying to use GStreamer python when built against system PyGObject with the following error importing Gst in there: ``` 12345678** (gst-plugin-scanner:710617): CRITICAL **: 11:45:02.343: can't find gi.repository.Gst Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/gi/repository/__init__.py", line 23, in <module> from ..importer import DynamicImporter File "/usr/lib64/python3.9/site-packages/gi/importer.py", line 33, in <module> from .overrides import load_overrides ImportError: cannot import name 'load_overrides' from 'gi.overrides' (/var/home/thiblahute/devel/gstreamer/gstreamer/subprojects/gst-editing-services/bindings/python/gi/overrides/__init__.py) Factory Details: ``` The approach to fixing it is to implement override `gi` in `gst-python/gi/` which we add to `PYTHONPATH`) and in there reset the `gi` module to the right place and we get overrides from paths from `_GI_OVERRIDES_PATH` we set in `gst-env.py` which points to all the overrides that will be installed. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1155>
Diffstat (limited to 'gst-env.py')
-rwxr-xr-xgst-env.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/gst-env.py b/gst-env.py
index 7b7d3ae7f7..c64042d92b 100755
--- a/gst-env.py
+++ b/gst-env.py
@@ -386,6 +386,7 @@ def get_subprocess_env(options, gst_version):
presets = set()
encoding_targets = set()
python_dirs = setup_gdb(options)
+ overrides_dirs = set()
if '--installed' in subprocess.check_output(meson + ['introspect', '-h']).decode():
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
for path, installpath in json.loads(installed_s.decode()).items():
@@ -406,7 +407,10 @@ def get_subprocess_env(options, gst_version):
if 'site-packages' in installpath_parts:
install_subpath = os.path.join(*installpath_parts[installpath_parts.index('site-packages') + 1:])
if path.endswith(install_subpath):
- python_dirs.add(path[:len (install_subpath) * -1])
+ if os.path.commonprefix(["gi/overrides", install_subpath]):
+ overrides_dirs.add(os.path.dirname(path))
+ else:
+ python_dirs.add(path[:len (install_subpath) * -1])
if path.endswith('.prs'):
presets.add(os.path.dirname(path))
@@ -432,11 +436,18 @@ def get_subprocess_env(options, gst_version):
for python_dir in sorted(python_dirs):
prepend_env_var(env, 'PYTHONPATH', python_dir, options.sysroot)
+ for python_dir in sorted(overrides_dirs):
+ prepend_env_var(env, '_GI_OVERRIDES_PATH', python_dir, options.sysroot)
+
mesonpath = os.path.join(SCRIPTDIR, "meson")
if os.path.join(mesonpath):
# Add meson/ into PYTHONPATH if we are using a local meson
prepend_env_var(env, 'PYTHONPATH', mesonpath, options.sysroot)
+ # Ensure that gst-python/gi is used first
+ prepend_env_var(env, "PYTHONPATH", os.path.join(SCRIPTDIR, 'subprojects', 'gst-python'),
+ options.sysroot)
+
# For devhelp books
if 'XDG_DATA_DIRS' not in env or not env['XDG_DATA_DIRS']:
# Preserve default paths when empty