python3/00251-change-user-install-location.patch

50 lines
1.9 KiB
Diff
Raw Normal View History

2019-09-30 11:14:35 -04:00
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
2021-11-13 10:52:43 +08:00
index 26696cf..1826cbc 100644
2019-09-30 11:14:35 -04:00
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
2021-11-13 10:52:43 +08:00
@@ -441,8 +441,19 @@ class install(Command):
2019-09-30 11:14:35 -04:00
raise DistutilsOptionError(
"must not supply exec-prefix without prefix")
2021-11-13 10:52:43 +08:00
2019-09-30 11:14:35 -04:00
- 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') or
+ sys.prefix != sys.base_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
2021-11-13 10:52:43 +08:00
2019-09-30 11:14:35 -04:00
else:
if self.exec_prefix is None:
diff --git a/Lib/site.py b/Lib/site.py
2021-11-13 10:52:43 +08:00
index 939893e..9bc1a5f 100644
2019-09-30 11:14:35 -04:00
--- a/Lib/site.py
+++ b/Lib/site.py
2021-11-13 10:52:43 +08:00
@@ -380,7 +380,14 @@ def getsitepackages(prefixes=None):
2019-09-30 11:14:35 -04:00
return sitepackages
2021-11-13 10:52:43 +08:00
2019-09-30 11:14:35 -04:00
def addsitepackages(known_paths, prefixes=None):
- """Add site-packages to sys.path"""
+ """Add site-packages to sys.path
+
+ '/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")
2021-11-13 10:52:43 +08:00
_trace("Processing global site-packages")
2019-09-30 11:14:35 -04:00
for sitedir in getsitepackages(prefixes):
if os.path.isdir(sitedir):
2021-11-13 10:52:43 +08:00
--
1.8.3.1