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

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