Skip to content

Commit

Permalink
Incorporate Fedora's distutil patch
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Nov 19, 2021
1 parent 514e9d0 commit c8fcf4d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions distutils/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,24 @@ def finalize_unix(self):
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:
Expand Down

0 comments on commit c8fcf4d

Please sign in to comment.