mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
Fix simply running testsuite in meson
- Make sure to never have root folder in sys.path when running meson, as pythondetector won't be able to access gi._overridesdir - Generate a mesonconfig.py file that will be used by the testsuite to know where meson generated files, making `python -m unittest` working.
This commit is contained in:
parent
cb0dd804f7
commit
fcbca025e3
5 changed files with 24 additions and 3 deletions
|
@ -12,7 +12,7 @@ gstpython = shared_library('_gi_gst',
|
|||
|
||||
# Workaround to get uninstalled working.
|
||||
foreach source: pysources
|
||||
run_command(python, '-c', 'import os; os.symlink("@0@/@1@", "@2@/@3@")'.format(
|
||||
run_command(python3, '-c', 'import os; os.symlink("@0@/@1@", "@2@/@3@")'.format(
|
||||
meson.current_source_dir(), source,
|
||||
meson.current_build_dir(), source))
|
||||
endforeach
|
||||
|
|
|
@ -21,7 +21,7 @@ gmodule_dep = dependency('gmodule-2.0')
|
|||
pygobject_dep = dependency('pygobject-3.0', version : '>= 3.0')
|
||||
python_dep = dependency('python3')
|
||||
|
||||
python = find_program('python3')
|
||||
python3 = import('python3').find_python()
|
||||
pythondetector = find_program('scripts/pythondetector')
|
||||
|
||||
cres = run_command(pythondetector, '--sosuffix')
|
||||
|
@ -83,5 +83,4 @@ subdir('gi')
|
|||
subdir('plugin')
|
||||
subdir('testsuite')
|
||||
|
||||
python3 = find_program('python3')
|
||||
run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
|
||||
|
|
|
@ -7,6 +7,12 @@ import sys
|
|||
from distutils import sysconfig
|
||||
|
||||
|
||||
try:
|
||||
sys.path.remove(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
'..')))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def get_python_abiflags():
|
||||
return sysconfig.get_config_var("ABIFLAGS")
|
||||
|
||||
|
|
|
@ -17,6 +17,14 @@ if not meson.is_subproject()
|
|||
endif
|
||||
endif
|
||||
|
||||
runcmd = run_command(python3, '-c', '''with open("@0@/mesonconfig.py", "w") as f:
|
||||
f.write("path='@1@'")'''.format(
|
||||
meson.current_source_dir(), join_paths(meson.current_build_dir(), '../')))
|
||||
|
||||
if runcmd.returncode() != 0
|
||||
error('Could not configure testsuite config file.' + runcmd.stderr())
|
||||
endif
|
||||
|
||||
foreach i: tests
|
||||
test_name = i.get(0)
|
||||
env = environment()
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
import os
|
||||
import gi.overrides
|
||||
|
||||
try:
|
||||
import mesonconfig
|
||||
except ImportError:
|
||||
mesonconfig = None
|
||||
pass
|
||||
|
||||
FILE = os.path.realpath(__file__)
|
||||
if not gi.overrides.__path__[0].endswith("gst-python/gi/overrides"):
|
||||
local_overrides = None
|
||||
|
@ -16,6 +22,8 @@ if not gi.overrides.__path__[0].endswith("gst-python/gi/overrides"):
|
|||
|
||||
gi.overrides.__path__.insert(0, local_overrides)
|
||||
|
||||
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__),
|
||||
|
|
Loading…
Reference in a new issue