uninstalled: use usercustomize, not sitecustomize
authorMartin Kelly <mkelly@xevo.com>
Wed, 22 Aug 2018 16:11:47 +0000 (09:11 -0700)
committerThibault Saunier <tsaunier@igalia.com>
Thu, 13 Sep 2018 10:05:33 +0000 (07:05 -0300)
Currently, gst-uninstalled is using sitecustomize.py for adding gi
override tweaks. However, if the standard Python libraries come before
this file in sys.path, then sitecustomize.py will never be run because
the "import sitecustomize" done in site.py will use the standard Python
libraries instead. This can be seen by running "import sitecustomize;
print(sitecustomize.__file__)" inside the uninstalled environment, as
well as by checking gi.override.__path__ and seeing that the tweaks are
missing (and the overrides are misbehaving).

Switch to using usercustomize.py, which has no match in the standard
libraries and thus will be correctly imported.

https://bugzilla.gnome.org/show_bug.cgi?id=797011

gst-uninstalled.py

index d4509ce..dfcf8b5 100755 (executable)
@@ -171,13 +171,13 @@ def setup_python_env(options, env):
     else:
         sitepackages = site.getusersitepackages()
 
-    sitecustomize = os.path.join(
+    usercustomize = os.path.join(
         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"), "usercustomize.py")
 
-    custom_user_sitepackage = os.path.dirname(sitecustomize)
+    custom_user_sitepackage = os.path.dirname(usercustomize)
     os.makedirs(custom_user_sitepackage, exist_ok=True)
-    with open(sitecustomize, "w") as f:
+    with open(usercustomize, "w") as f:
          f.write("""import os
 import gi.overrides