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

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