Fedora < 36 only: Instruct pip to use distutils

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2014513
This commit is contained in:
Miro Hrončok 2021-11-12 12:31:26 +01:00
parent f7c55a4f2f
commit b7b2fa452d
2 changed files with 38 additions and 5 deletions

View File

@ -2,17 +2,27 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michal Cyprian <m.cyprian@gmail.com>
Date: Mon, 26 Jun 2017 16:32:56 +0200
Subject: [PATCH] 00251: Change user install location
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Set values of prefix and exec_prefix in distutils install command
to /usr/local if executable is /usr/bin/python* and RPM build
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: Awaiting resources to work on upstream PEP
Downstream only: Reworked in Fedora 36+ to follow https://bugs.python.org/issue43976
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/site.py | 9 ++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
Lib/sysconfig.py | 4 ++++
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 26696cfb9d..1826cbcb38 100644
@ -61,3 +71,18 @@ index 939893eb5e..d1316c3355 100644
for sitedir in getsitepackages(prefixes):
if os.path.isdir(sitedir):
addsitedir(sitedir, known_paths)
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 95b48f6429..f78b374748 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -58,6 +58,10 @@
},
}
+# Force pip to use distutils paths instead of sysconfig
+# https://github.com/pypa/pip/issues/10647
+_PIP_USE_SYSCONFIG = False
+
# NOTE: site.py has copy of this function.
# Sync it when modify this function.

View File

@ -17,7 +17,7 @@ URL: https://www.python.org/
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 1%{?dist}
Release: 2%{?dist}
License: Python
@ -267,7 +267,7 @@ Source11: idle3.appdata.xml
# Was Patch0 in ivazquez' python3000 specfile
Patch1: 00001-rpath.patch
# 00251 # 5c445123f04d96be42a35eef5119378ba1713a96
# 00251 # f9b6509e62a9b05c96470903cb0280760c443e29
# Change user install location
#
# Set values of prefix and exec_prefix in distutils install command
@ -275,7 +275,11 @@ Patch1: 00001-rpath.patch
# 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: Awaiting resources to work on upstream PEP
# Downstream only: Reworked in Fedora 36+ to follow https://bugs.python.org/issue43976
#
# 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
Patch251: 00251-change-user-install-location.patch
# 00328 # 318e500c98f5e59eb1f23e0fcd32db69b9bd17e1
@ -1592,6 +1596,10 @@ CheckPython optimized
# ======================================================
%changelog
* Thu Dec 09 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10.1-2
- Instruct pip to use distutils
- Fixes rhbz#2014513
* Tue Dec 07 2021 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.10.1-1
- Update to 3.10.1