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

70a2d8
From 76330e0a8798b3b03160edc7e8d42d3dbee756fd Mon Sep 17 00:00:00 2001
70a2d8
From: Michal Cyprian <m.cyprian@gmail.com>
70a2d8
Date: Mon, 26 Jun 2017 16:32:56 +0200
70a2d8
Subject: [PATCH] 00251: Change user install location
70a2d8
70a2d8
Set values of prefix and exec_prefix in distutils install command
70a2d8
to /usr/local if executable is /usr/bin/python* and RPM build
70a2d8
is not detected to make pip and distutils install into separate location.
70a2d8
70a2d8
Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
70a2d8
---
70a2d8
 Lib/distutils/command/install.py | 15 +++++++++++++--
70a2d8
 Lib/site.py                      |  9 ++++++++-
70a2d8
 2 files changed, 21 insertions(+), 3 deletions(-)
70a2d8
70a2d8
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
70a2d8
index ae4f915669..0e4fd5b74a 100644
70a2d8
--- a/Lib/distutils/command/install.py
70a2d8
+++ b/Lib/distutils/command/install.py
70a2d8
@@ -418,8 +418,19 @@ class install(Command):
70a2d8
                     raise DistutilsOptionError(
70a2d8
                           "must not supply exec-prefix without prefix")
70a2d8
 
70a2d8
-                self.prefix = os.path.normpath(sys.prefix)
70a2d8
-                self.exec_prefix = os.path.normpath(sys.exec_prefix)
70a2d8
+                # self.prefix is set to sys.prefix + /local/
70a2d8
+                # if neither RPM build nor virtual environment is
70a2d8
+                # detected to make pip and distutils install packages
70a2d8
+                # into the separate location.
70a2d8
+                if (not (hasattr(sys, 'real_prefix') or
70a2d8
+                    sys.prefix != sys.base_prefix) and
70a2d8
+                    'RPM_BUILD_ROOT' not in os.environ):
70a2d8
+                    addition = "/local"
70a2d8
+                else:
70a2d8
+                    addition = ""
70a2d8
+
70a2d8
+                self.prefix = os.path.normpath(sys.prefix) + addition
70a2d8
+                self.exec_prefix = os.path.normpath(sys.exec_prefix) + addition
70a2d8
 
70a2d8
             else:
70a2d8
                 if self.exec_prefix is None:
70a2d8
diff --git a/Lib/site.py b/Lib/site.py
70a2d8
index 22d53fa562..9513526109 100644
70a2d8
--- a/Lib/site.py
70a2d8
+++ b/Lib/site.py
70a2d8
@@ -348,7 +348,14 @@ def getsitepackages(prefixes=None):
70a2d8
     return sitepackages
70a2d8
 
70a2d8
 def addsitepackages(known_paths, prefixes=None):
70a2d8
-    """Add site-packages to sys.path"""
70a2d8
+    """Add site-packages to sys.path
70a2d8
+
70a2d8
+    '/usr/local' is included in PREFIXES if RPM build is not detected
70a2d8
+    to make packages installed into this location visible.
70a2d8
+
70a2d8
+    """
70a2d8
+    if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ:
70a2d8
+        PREFIXES.insert(0, "/opt/rh/rh-python38/root/usr/local")
70a2d8
     for sitedir in getsitepackages(prefixes):
70a2d8
         if os.path.isdir(sitedir):
70a2d8
             addsitedir(sitedir, known_paths)
70a2d8
-- 
70a2d8
2.21.0
70a2d8