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

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