install_dir : pygi_override_dir,
include_directories : [configinc],
dependencies : [gst_dep, python_dep, pygobject_dep])
-
-gi_overrides_build_dir = meson.current_build_dir()
-
-# Workaround to get uninstalled working.
-foreach source: pysources
- run_command(python, '-c', 'import os; os.symlink("@0@/@1@", "@2@/@3@")'.format(
- meson.current_source_dir(), source,
- gi_overrides_build_dir, source))
-endforeach
# Don't try to use wildcards to replace the list of tests below.
# http://www.gnu.org/software/automake/manual/automake.html#Wildcards
# Keep this list sorted!
+
+TEST_ENVIRONMENT = \
+ GST_OVERRIDE_SRC_PATH="$(abs_top_srcdir)/gi/overrides" \
+ GST_OVERRIDE_BUILD_PATH="$(abs_top_builddir)/gi/overrides"
+
tests = \
test_gst.py \
test_types.py
rm -rf *.pyc *.pyo
check-local:
- $(PYTHON) $(srcdir)/runtests.py $(tests)
+ $(TEST_ENVIRONMENT) $(PYTHON) $(srcdir)/runtests.py $(tests)
%.check: %
- $(PYTHON) $(srcdir)/runtests.py $*
+ $(TEST_ENVIRONMENT) $(PYTHON) $(srcdir)/runtests.py $*
%.forever: %
$(srcdir)/cleanup.py
@while true; do \
error('Could not configure testsuite config file.' + runcmd.stderr())
endif
-gi_dir = join_paths(pygi_override_dir, '..', '..')
-
foreach i: tests
test_name = i.get(0)
env = environment()
- env.prepend('PYTHONPATH', [gi_dir, gi_overrides_build_dir])
+ env.set('GST_OVERRIDE_SRC_PATH', join_paths (meson.current_source_dir(), '..', 'gi', 'overrides'))
+ env.set('GST_OVERRIDE_BUILD_PATH', join_paths (meson.current_build_dir(), '..', 'gi', 'overrides'))
test(test_name, python, args: [runtests, i.get(1)], env: env)
endforeach
import os
-import gi.overrides
+import sys
+import imp
-try:
- import mesonconfig
-except ImportError:
- mesonconfig = None
- pass
+class GstOverrideImport:
+ def find_module(self, fullname, path=None):
+ if fullname in ('gi.overrides.Gst', 'gi.overrides._gi_gst'):
+ return self
+ return None
-FILE = os.path.realpath(__file__)
-if not gi.overrides.__path__[0].endswith("gst-python/gi/overrides"):
- local_overrides = None
- # our overrides don't take precedence, let's fix it
- for i, path in enumerate(gi.overrides.__path__):
- if path.endswith("gst-python/gi/overrides"):
- local_overrides = path
+ def load_module(self, name):
+ if name in sys.modules:
+ return sys.modules[name]
- if local_overrides:
- gi.overrides.__path__.remove(local_overrides)
- else:
- local_overrides = os.path.abspath(os.path.join(FILE, "../", "../", "gi", "overrides"))
+ fp, pathname, description = imp.find_module(name.split('.')[-1], [
+ os.environ.get('GST_OVERRIDE_SRC_PATH'),
+ os.environ.get('GST_OVERRIDE_BUILD_PATH'),
+ ])
- gi.overrides.__path__.insert(0, local_overrides)
+ try:
+ module = imp.load_module(name, fp, pathname, description)
+ finally:
+ if fp:
+ fp.close()
+ sys.modules[name] = module
+ return module
-if mesonconfig:
- gi.overrides.__path__.insert(0, os.path.abspath(os.path.join(mesonconfig.path, "gi", "overrides")))
-# Execute previously set sitecustomize.py script if it existed
-if os.environ.get("GST_ENV"):
- old_sitecustomize = os.path.join(os.path.dirname(__file__),
- "old.sitecustomize.gstuninstalled.py")
- if os.path.exists(old_sitecustomize):
- exec(compile(open(old_sitecustomize).read(), old_sitecustomize, 'exec'))
+sys.meta_path.insert(0, GstOverrideImport())