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

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