EL 9 specific: Adjust our patch to get wheels from /usr/share/python%{python3_pkgversion}-wheels

In RHEL 9, the wheels are located in:

 - For Python 3.9: /usr/share/python3-wheels
 - For Python 3.11: /usr/share/python3.11-wheels

This changes our patch to use RPM packaged wheels from the appropriate directories.
Is should work with future Python versions as well, assuming nothing changes in RHEL.
epel9
Miro Hrončok 2 years ago
parent 81f2509482
commit 6e2063b014

@ -1,6 +1,6 @@
Name: python-virtualenv
Version: 20.17.1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Tool to create isolated Python environments
License: MIT
@ -85,10 +85,6 @@ rm src/virtualenv/seed/wheels/embed/wheel-*
test ! -f src/virtualenv/seed/embed/wheels/*.whl
# Replace hardcoded path from rpm-wheels.patch by %%{python_wheel_dir}
# On Fedora, this should change nothing, but when building for RHEL9+, it will
sed -i "s|/usr/share/python-wheels|%{python_wheel_dir}|" src/virtualenv/util/path/_system_wheels.py
# Relax the upper bounds of some dependencies to their known available versions in EL 9
# We run tests and CI to verify nothing broke
sed -i -e 's/distlib>=0.3.6/distlib>=0.3.2/' \
@ -145,6 +141,9 @@ rm -r tmp_path
%changelog
* Mon Jan 30 2023 Miro Hrončok <mhroncok@redhat.com> - 20.17.1-2
- Use wheels from /usr/share/python3.11-wheels when creating Python 3.11 virtual environments
* Wed Dec 07 2022 Lumír Balhar <lbalhar@redhat.com> - 20.17.1-1
- Update to 20.17.1 (rhbz#2151044)

@ -1,16 +1,16 @@
From 5ba67ace2437432ee78d21c68dfbb785ad0e9723 Mon Sep 17 00:00:00 2001
From 9c2b528d300f4b8e4ccc7b81d68fdfd054214f80 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Thu, 27 Oct 2022 11:50:54 +0200
Subject: [PATCH] RPM wheels
---
src/virtualenv/run/__init__.py | 5 +++--
src/virtualenv/seed/embed/base_embed.py | 16 +++++++++++++-
src/virtualenv/run/__init__.py | 5 ++--
src/virtualenv/seed/embed/base_embed.py | 16 ++++++++++-
src/virtualenv/seed/embed/pip_invoke.py | 1 +
.../seed/embed/via_app_data/via_app_data.py | 1 +
src/virtualenv/seed/wheels/embed/__init__.py | 3 +++
src/virtualenv/util/path/_system_wheels.py | 21 +++++++++++++++++++
6 files changed, 44 insertions(+), 3 deletions(-)
src/virtualenv/util/path/_system_wheels.py | 27 +++++++++++++++++++
6 files changed, 50 insertions(+), 3 deletions(-)
create mode 100644 src/virtualenv/util/path/_system_wheels.py
diff --git a/src/virtualenv/run/__init__.py b/src/virtualenv/run/__init__.py
@ -30,7 +30,7 @@ index 6d22b71..19d1791 100644
def load_app_data(args, parser, options):
diff --git a/src/virtualenv/seed/embed/base_embed.py b/src/virtualenv/seed/embed/base_embed.py
index f29110b..260b1a9 100644
index f29110b..07649c2 100644
--- a/src/virtualenv/seed/embed/base_embed.py
+++ b/src/virtualenv/seed/embed/base_embed.py
@@ -3,8 +3,9 @@ from pathlib import Path
@ -65,7 +65,7 @@ index f29110b..260b1a9 100644
return result[:-1] + ")"
+ def insert_system_wheels_paths(self, creator):
+ system_wheels_paths = get_system_wheels_paths(creator.interpreter.executable)
+ system_wheels_paths = get_system_wheels_paths(creator.interpreter)
+ self.extra_search_dir = list(system_wheels_paths) + self.extra_search_dir
+
@ -96,7 +96,7 @@ index f31ecf6..d7a0f5a 100644
pip_version = name_to_whl["pip"].version_tuple if "pip" in name_to_whl else None
installer_class = self.installer_class(pip_version)
diff --git a/src/virtualenv/seed/wheels/embed/__init__.py b/src/virtualenv/seed/wheels/embed/__init__.py
index 3bd41ba..cd0c86c 100644
index 4d3108e..e6e2730 100644
--- a/src/virtualenv/seed/wheels/embed/__init__.py
+++ b/src/virtualenv/seed/wheels/embed/__init__.py
@@ -47,8 +47,11 @@ BUNDLE_SUPPORT = {
@ -113,18 +113,19 @@ index 3bd41ba..cd0c86c 100644
diff --git a/src/virtualenv/util/path/_system_wheels.py b/src/virtualenv/util/path/_system_wheels.py
new file mode 100644
index 0000000..19cf2ca
index 0000000..fc7e942
--- /dev/null
+++ b/src/virtualenv/util/path/_system_wheels.py
@@ -0,0 +1,21 @@
@@ -0,0 +1,27 @@
+from pathlib import Path
+from subprocess import check_output, CalledProcessError
+
+
+def get_system_wheels_paths(executable):
+def get_system_wheels_paths(interpreter):
+ # ensurepip wheels
+ # We need subprocess here to check ensurepip with the Python we are creating
+ # a new virtual environment for
+ executable = interpreter.executable
+ try:
+ ensurepip_path = check_output((executable, "-u", "-c", 'import ensurepip; print(ensurepip.__path__[0])'), universal_newlines=True)
+ ensurepip_path = Path(ensurepip_path.strip()) / "_bundled"
@ -135,9 +136,14 @@ index 0000000..19cf2ca
+ yield ensurepip_path
+
+ # Standard wheels path
+ wheels_dir = Path("/usr/share/python-wheels")
+ # The EL 9 main Python has just 3 (this is the %{python3_pkgversion} RPM macro)
+ if interpreter.version_info[:2] == (3, 9):
+ python3_pkgversion = "3"
+ else:
+ python3_pkgversion = "{0.major}.{0.minor}".format(interpreter.version_info)
+ wheels_dir = Path(f"/usr/share/python{python3_pkgversion}-wheels")
+ if wheels_dir.exists():
+ yield wheels_dir
--
2.37.3
2.39.1

Loading…
Cancel
Save