summaryrefslogtreecommitdiff
path: root/distutils/command
diff options
context:
space:
mode:
authorMiro Hrončok <miro@hroncok.cz>2021-11-19 16:50:31 +0100
committerMiro Hrončok <miro@hroncok.cz>2021-11-19 16:50:31 +0100
commitc8fcf4d2e3aaf543f065971dcf78451be35adcc4 (patch)
treefa9f60079f3cc369486256b3efa20adae3ce55e2 /distutils/command
parent514e9d03acb51ea93205c1fd0d336174c9481de7 (diff)
downloadpython-setuptools-git-c8fcf4d2e3aaf543f065971dcf78451be35adcc4.tar.gz
Incorporate Fedora's distutil patch
See https://github.com/pypa/setuptools/pull/2896#issuecomment-973983395
Diffstat (limited to 'distutils/command')
-rw-r--r--distutils/command/install.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/distutils/command/install.py b/distutils/command/install.py
index c756b6db..dbc83fce 100644
--- a/distutils/command/install.py
+++ b/distutils/command/install.py
@@ -471,8 +471,24 @@ 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)
+ # Fedora (and Fedora derived distros) used to patch distutils
+ # until Fedora 36 and/or Python 3.11.
+ # Here, we preserve that behavior conditionally on a special
+ # _distutils_mangle_rpm_prefix attribute of sysconfig
+ # that Fedora sets on their older Pythons to support this check.
+ # When it is set and true-ish,
+ # self.prefix is set to sys.prefix + /local/
+ # if neither RPM build nor virtual environment is
+ # detected to make pip and distutils install packages to /usr/local.
+ addition = ""
+ if (getattr(sysconfig, "_distutils_mangle_rpm_prefix", False) and
+ not (hasattr(sys, 'real_prefix') or
+ sys.prefix != sys.base_prefix) and
+ 'RPM_BUILD_ROOT' not in os.environ):
+ addition = "/local"
+
+ 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: