churchyard / rpms / python3

Forked from rpms/python3 3 years ago
Clone

Blame 00251-set-python3-prefixes.patch

24515db
diff --git a/Lib/site.py b/Lib/site.py
24515db
index ad1033e..f2fb028 100644
24515db
--- a/Lib/site.py
24515db
+++ b/Lib/site.py
24515db
@@ -537,6 +537,23 @@ def execusercustomize():
24515db
                 (err.__class__.__name__, err))
24515db
24515db
24515db
+def set_prefixes():
24515db
+    """Set values of prefix and exec_prefix to /usr/local if executable is
24515db
+    /usr/bin/python* to make pip and distutils install into separate location.
24515db
+
24515db
+    New value of sys.prefix is inserted to PREFIXES list that contains
24515db
+    it's previous value. Both paths /usr/lib/pythonX.Y/site-packages and
24515db
+    /usr/local/lib/pythonX.Y/site-packages will be included in sys.path.
24515db
+    """
24515db
+    global PREFIXES
24515db
+    global ENABLE_USER_SITE
24515db
+
24515db
+    if sys.executable.startswith("/usr/bin/python"):
24515db
+        sys.prefix = sys.exec_prefix = "/usr/local"
24515db
+        if ENABLE_USER_SITE:
24515db
+            PREFIXES.insert(0, sys.prefix)
24515db
+
24515db
+
24515db
 def main():
24515db
     """Add standard site-specific directories to the module search path.
24515db
24515db
@@ -550,6 +567,7 @@ def main():
24515db
     known_paths = venv(known_paths)
24515db
     if ENABLE_USER_SITE is None:
24515db
         ENABLE_USER_SITE = check_enableusersite()
24515db
+    set_prefixes()
24515db
     known_paths = addusersitepackages(known_paths)
24515db
     known_paths = addsitepackages(known_paths)
24515db
     setquit()