uninstalled: Also support GES overrides

Simplifying one step further too
This commit is contained in:
Thibault Saunier 2018-07-24 12:28:48 -04:00
parent 6a0c4b3771
commit 7ec215b509

View file

@ -152,11 +152,19 @@ def in_venv():
(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)) (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))
def setup_python_env(options, env): def setup_python_env(options, env):
subprojects_path = os.path.join(options.builddir, "subprojects") some_overrides_built = False
gst_python_path = os.path.join(SCRIPTDIR, "subprojects", "gst-python") for override_path in [os.path.join("subprojects", "gst-editing-services", "bindings", "python", "gi", "overrides"),
if not os.path.exists(os.path.join(subprojects_path, "gst-python")) or \ os.path.join("subprojects", "gst-python", "gi", "overrides")]:
not os.path.exists(gst_python_path): if os.path.exists(os.path.join(SCRIPTDIR, override_path)):
return False some_overrides_built = True
else:
continue
prepend_env_var(env, "PYGOBJECT_OVERRIDES_PATH", os.path.join(SCRIPTDIR, override_path))
prepend_env_var(env, "PYGOBJECT_OVERRIDES_PATH", os.path.join(options.builddir, override_path))
if not some_overrides_built:
return
if in_venv (): if in_venv ():
sitepackages = get_python_lib() sitepackages = get_python_lib()
@ -167,16 +175,15 @@ def setup_python_env(options, env):
subprocess.check_output([sys.executable, '-c', 'import site; print(site.USER_SITE)'], subprocess.check_output([sys.executable, '-c', 'import site; print(site.USER_SITE)'],
env={"PYTHONUSERBASE": PREFIX_DIR}).decode().strip("\n"), "sitecustomize.py") env={"PYTHONUSERBASE": PREFIX_DIR}).decode().strip("\n"), "sitecustomize.py")
custom_sitecustomize = os.path.dirname(sitecustomize) custom_user_sitepackage = os.path.dirname(sitecustomize)
overrides_hack = os.path.join(gst_python_path, "testsuite", "overrides_hack.py") os.makedirs(custom_user_sitepackage, exist_ok=True)
mesonconfig = os.path.join(gst_python_path, "testsuite", "mesonconfig.py") with open(sitecustomize, "w") as f:
mesonconfig_link = os.path.join(custom_sitecustomize, "mesonconfig.py") f.write("""import os
import gi.overrides
os.makedirs(custom_sitecustomize, exist_ok=True) for override_path in os.environ.get("PYGOBJECT_OVERRIDES_PATH", "").split(os.pathsep):
with contextlib.suppress(FileExistsError): gi.overrides.__path__.insert(0, override_path)
os.symlink(overrides_hack, sitecustomize) """)
with contextlib.suppress(FileExistsError):
os.symlink(mesonconfig, mesonconfig_link)
env["PYTHONUSERBASE"] = PREFIX_DIR env["PYTHONUSERBASE"] = PREFIX_DIR
if sitepackages: if sitepackages: