Instruct pypa/distutils to add /local/ addition to prefix
This commit is contained in:
parent
b7b2fa452d
commit
7c6eb17d2b
|
@ -13,40 +13,42 @@ is not detected to make pip and distutils install into separate location.
|
|||
Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
Downstream only: Reworked in Fedora 36+ to follow https://bugs.python.org/issue43976
|
||||
|
||||
pypa/distutils integration: https://github.com/pypa/distutils/pull/70
|
||||
|
||||
Also set sysconfig._PIP_USE_SYSCONFIG = False, to force pip-upgraded-pip
|
||||
to respect this patched distutils install command.
|
||||
See https://bugzilla.redhat.com/show_bug.cgi?id=2014513
|
||||
|
||||
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
|
||||
---
|
||||
Lib/distutils/command/install.py | 15 +++++++++++++--
|
||||
Lib/distutils/command/install.py | 8 ++++++--
|
||||
Lib/site.py | 9 ++++++++-
|
||||
Lib/sysconfig.py | 4 ++++
|
||||
3 files changed, 25 insertions(+), 3 deletions(-)
|
||||
Lib/sysconfig.py | 16 ++++++++++++++++
|
||||
3 files changed, 30 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
|
||||
index 26696cfb9d..1826cbcb38 100644
|
||||
index 01d5331a63..79f70f0de4 100644
|
||||
--- a/Lib/distutils/command/install.py
|
||||
+++ b/Lib/distutils/command/install.py
|
||||
@@ -441,8 +441,19 @@ def finalize_unix(self):
|
||||
@@ -159,6 +159,8 @@ class install(Command):
|
||||
|
||||
negative_opt = {'no-compile' : 'compile'}
|
||||
|
||||
+ # Allow Fedora to add components to the prefix
|
||||
+ _prefix_addition = getattr(sysconfig, '_prefix_addition', '')
|
||||
|
||||
def initialize_options(self):
|
||||
"""Initializes options."""
|
||||
@@ -441,8 +443,10 @@ 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)
|
||||
+ # 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
|
||||
+ self.prefix = (
|
||||
+ os.path.normpath(sys.prefix) + self._prefix_addition)
|
||||
+ self.exec_prefix = (
|
||||
+ os.path.normpath(sys.exec_prefix) + self._prefix_addition)
|
||||
|
||||
else:
|
||||
if self.exec_prefix is None:
|
||||
|
@ -72,16 +74,28 @@ index 939893eb5e..d1316c3355 100644
|
|||
if os.path.isdir(sitedir):
|
||||
addsitedir(sitedir, known_paths)
|
||||
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
||||
index 95b48f6429..f78b374748 100644
|
||||
index daf9f00006..b88f9a9de0 100644
|
||||
--- a/Lib/sysconfig.py
|
||||
+++ b/Lib/sysconfig.py
|
||||
@@ -58,6 +58,10 @@
|
||||
@@ -58,6 +58,22 @@
|
||||
},
|
||||
}
|
||||
|
||||
+# Force pip to use distutils paths instead of sysconfig
|
||||
+# https://github.com/pypa/pip/issues/10647
|
||||
+_PIP_USE_SYSCONFIG = False
|
||||
+
|
||||
+# This is used by distutils.command.install in the stdlib
|
||||
+# as well as pypa/distutils (e.g. bundled in setuptools).
|
||||
+# The self.prefix value is set to sys.prefix + /local/
|
||||
+# if neither RPM build nor virtual environment is
|
||||
+# detected to make distutils install packages
|
||||
+# into the separate location.
|
||||
+# https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
+if (not (hasattr(sys, 'real_prefix') or
|
||||
+ sys.prefix != sys.base_prefix) and
|
||||
+ 'RPM_BUILD_ROOT' not in os.environ):
|
||||
+ _prefix_addition = "/local"
|
||||
+
|
||||
|
||||
# NOTE: site.py has copy of this function.
|
||||
|
|
|
@ -267,7 +267,7 @@ Source11: idle3.appdata.xml
|
|||
# Was Patch0 in ivazquez' python3000 specfile
|
||||
Patch1: 00001-rpath.patch
|
||||
|
||||
# 00251 # f9b6509e62a9b05c96470903cb0280760c443e29
|
||||
# 00251 # 08a62456431df182dfad18ad75838f769aca2d08
|
||||
# Change user install location
|
||||
#
|
||||
# Set values of prefix and exec_prefix in distutils install command
|
||||
|
@ -277,6 +277,8 @@ Patch1: 00001-rpath.patch
|
|||
# Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||
# Downstream only: Reworked in Fedora 36+ to follow https://bugs.python.org/issue43976
|
||||
#
|
||||
# pypa/distutils integration: https://github.com/pypa/distutils/pull/70
|
||||
#
|
||||
# Also set sysconfig._PIP_USE_SYSCONFIG = False, to force pip-upgraded-pip
|
||||
# to respect this patched distutils install command.
|
||||
# See https://bugzilla.redhat.com/show_bug.cgi?id=2014513
|
||||
|
@ -1598,6 +1600,7 @@ CheckPython optimized
|
|||
%changelog
|
||||
* Thu Dec 09 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10.1-2
|
||||
- Instruct pip to use distutils
|
||||
- Instruct pypa/distutils to add /local/ addition to prefix
|
||||
- Fixes rhbz#2014513
|
||||
|
||||
* Tue Dec 07 2021 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.10.1-1
|
||||
|
|
Loading…
Reference in New Issue