Update patch 251 to include specific install scheme for virtualenv

This commit is contained in:
Lumir Balhar 2021-11-09 18:20:35 +01:00
parent 4f08fc3037
commit d5c558ed2a
2 changed files with 21 additions and 8 deletions

View File

@ -2,6 +2,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Mon, 15 Feb 2021 12:19:27 +0100
Subject: [PATCH] 00251: Change user install location
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Change the values of sysconfig's "posix_prefix" install scheme to /usr/local
when RPM build or venv/virtualenv is not detected,
@ -22,11 +25,12 @@ Downstream only for now, waiting for https://bugs.python.org/issue43976
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Michal Cyprian <m.cyprian@gmail.com>
Co-authored-by: Lumír Balhar <frenzy.madness@gmail.com>
---
Lib/site.py | 9 ++++++++-
Lib/sysconfig.py | 19 +++++++++++++++++++
Lib/sysconfig.py | 25 +++++++++++++++++++++++++
Lib/test/test_sysconfig.py | 4 +++-
3 files changed, 30 insertions(+), 2 deletions(-)
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/Lib/site.py b/Lib/site.py
index 939893eb5e..d1316c3355 100644
@ -50,16 +54,22 @@ 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..226b55a556 100644
index 95b48f6429..86072868d6 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -58,6 +58,25 @@
@@ -58,6 +58,31 @@
},
}
+# backup the original posix_prefix as rpm_prefix
+# RPM packages use it and we need to be able to read it even when changed
+_INSTALL_SCHEMES['rpm_prefix'] = _INSTALL_SCHEMES['posix_prefix']
+# Virtualenv >= 20.10.0 favors the "venv" scheme over the defaults when creating virtual environments.
+# See: https://github.com/pypa/virtualenv/commit/8da79db86d8a5c74d03667a40e64ff832076445e
+# See: https://bugs.python.org/issue45413
+# "venv" should be the same as the unpatched posix_prefix for us,
+# so new virtual environments aren't created with paths like venv/local/bin/python.
+_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_prefix']
+
+if (not (hasattr(sys, 'real_prefix') or
+ sys.prefix != sys.base_prefix) and
@ -80,7 +90,7 @@ index 95b48f6429..226b55a556 100644
# NOTE: site.py has copy of this function.
# Sync it when modify this function.
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 9408657c91..db4cbc55ec 100644
index 9408657c91..fd49b2bcce 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -263,7 +263,7 @@ def test_get_config_h_filename(self):
@ -88,7 +98,7 @@ index 9408657c91..db4cbc55ec 100644
def test_get_scheme_names(self):
- wanted = ['nt', 'posix_home', 'posix_prefix']
+ wanted = ['nt', 'posix_home', 'posix_prefix', 'rpm_prefix']
+ wanted = ['nt', 'posix_home', 'posix_prefix', 'rpm_prefix', 'venv']
if HAS_USER_BASE:
wanted.extend(['nt_user', 'osx_framework_user', 'posix_user'])
self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))

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: 2%{?dist}
Release: 3%{?dist}
License: Python
@ -267,7 +267,7 @@ Source11: idle3.appdata.xml
# Was Patch0 in ivazquez' python3000 specfile
Patch1: 00001-rpath.patch
# 00251 # 0952e38e5bf725ebbab48b13a35566e30635ddf8
# 00251 # 531494a5ded29dad59f617304dab4eb8b7f80b0b
# Change user install location
#
# Change the values of sysconfig's "posix_prefix" install scheme to /usr/local
@ -1596,6 +1596,9 @@ CheckPython optimized
# ======================================================
%changelog
* Tue Nov 09 2021 Lumír Balhar <lbalhar@redhat.com> - 3.10.0-3
- Update patch 251 to include specific install scheme for virtualenv
* Tue Oct 05 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10.0-2
- Change the values of sysconfig's "posix_prefix" install scheme to /usr/local
when RPM build or venv/virtualenv is not detected,