File adapted-from-F00251-change-user-install-location.patch of Package python

Index: Python-2.7.17/Lib/distutils/command/install.py
===================================================================
--- Python-2.7.17.orig/Lib/distutils/command/install.py
+++ Python-2.7.17/Lib/distutils/command/install.py
@@ -431,8 +431,18 @@ class install (Command):
                     raise DistutilsOptionError, \
                           "must not supply exec-prefix without prefix"
 
-                self.prefix = os.path.normpath(sys.prefix)
-                self.exec_prefix = os.path.normpath(sys.exec_prefix)
+                # self.prefix is set to sys.prefix + /local/
+                # if neither RPM build nor virtual environment is
+                # detected to make pip and distutils install packages
+                # into the separate location.
+                if (not hasattr(sys, 'real_prefix') and
+                    'RPM_BUILD_ROOT' not in os.environ):
+                    addition = "/local"
+                else:
+                    addition = ""
+
+                self.prefix = os.path.normpath(sys.prefix) + addition
+                self.exec_prefix = os.path.normpath(sys.exec_prefix) + addition
 
             else:
                 if self.exec_prefix is None:
Index: Python-2.7.17/Lib/site.py
===================================================================
--- Python-2.7.17.orig/Lib/site.py
+++ Python-2.7.17/Lib/site.py
@@ -291,6 +291,10 @@ def getsitepackages():
     sitepackages = []
     seen = set()
 
+    # '/usr/local' is included in PREFIXES if RPM build is not detected
+    # to make packages installed into this location visible.
+    if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ:
+        PREFIXES.insert(0, "/usr/local")
     for prefix in PREFIXES:
         if not prefix or prefix in seen:
             continue