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

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