churchyard / rpms / python3

Forked from rpms/python3 4 years ago
Clone

Blame 00251-change-user-install-location.patch

332b947
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
08ffd08
index 0258d3d..4ebf50a 100644
332b947
--- a/Lib/distutils/command/install.py
332b947
+++ b/Lib/distutils/command/install.py
08ffd08
@@ -418,8 +418,19 @@ class install(Command):
332b947
                     raise DistutilsOptionError(
332b947
                           "must not supply exec-prefix without prefix")
332b947
332b947
-                self.prefix = os.path.normpath(sys.prefix)
332b947
-                self.exec_prefix = os.path.normpath(sys.exec_prefix)
332b947
+                # self.prefix is set to sys.prefix + /local/
08ffd08
+                # if neither RPM build nor virtual environment is
08ffd08
+                # detected to make pip and distutils install packages
08ffd08
+                # into the separate location.
08ffd08
+                if (not (hasattr(sys, 'real_prefix') or
08ffd08
+                    sys.prefix != sys.base_prefix) and
08ffd08
+                    'RPM_BUILD_ROOT' not in os.environ):
332b947
+                    addition = "/local"
332b947
+                else:
332b947
+                    addition = ""
332b947
+
332b947
+                self.prefix = os.path.normpath(sys.prefix) + addition
332b947
+                self.exec_prefix = os.path.normpath(sys.exec_prefix) + addition
332b947
332b947
             else:
332b947
                 if self.exec_prefix is None:
332b947
diff --git a/Lib/site.py b/Lib/site.py
08ffd08
index 0fc9200..c95202e 100644
332b947
--- a/Lib/site.py
332b947
+++ b/Lib/site.py
08ffd08
@@ -322,7 +322,14 @@ def getsitepackages(prefixes=None):
332b947
     return sitepackages
332b947
332b947
 def addsitepackages(known_paths, prefixes=None):
332b947
-    """Add site-packages to sys.path"""
08ffd08
+    """Add site-packages to sys.path
332b947
+
08ffd08
+    '/usr/local' is included in PREFIXES if RPM build is not detected
08ffd08
+    to make packages installed into this location visible.
332b947
+
332b947
+    """
08ffd08
+    if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ:
332b947
+        PREFIXES.insert(0, "/usr/local")
332b947
     for sitedir in getsitepackages(prefixes):
332b947
         if os.path.isdir(sitedir):
332b947
             addsitedir(sitedir, known_paths)