churchyard / rpms / python3

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