Blame SOURCES/00189-use-rpm-wheels.patch

93a1c0
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
93a1c0
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
93a1c0
Date: Wed, 15 Aug 2018 15:36:29 +0200
93a1c0
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
93a1c0
93a1c0
We keep them in /usr/share/python-wheels
93a1c0
93a1c0
Downstream only: upstream bundles
93a1c0
We might eventually pursuit upstream support, but it's low prio
93a1c0
---
93a1c0
 Lib/ensurepip/__init__.py | 33 ++++++++++++++++++++++-----------
93a1c0
 1 file changed, 22 insertions(+), 11 deletions(-)
93a1c0
93a1c0
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
93a1c0
index 97dfa7ea71..984e587ea0 100644
93a1c0
--- a/Lib/ensurepip/__init__.py
93a1c0
+++ b/Lib/ensurepip/__init__.py
93a1c0
@@ -1,3 +1,5 @@
93a1c0
+import distutils.version
93a1c0
+import glob
93a1c0
 import os
93a1c0
 import os.path
93a1c0
 import sys
93a1c0
@@ -6,16 +8,28 @@ import tempfile
93a1c0
 import subprocess
93a1c0
 from importlib import resources
93a1c0
 
93a1c0
-from . import _bundled
93a1c0
-
93a1c0
 
93a1c0
 
93a1c0
 __all__ = ["version", "bootstrap"]
93a1c0
 
93a1c0
+_WHEEL_DIR = "/usr/share/python39-wheels/"
93a1c0
 
ac4541
-_SETUPTOOLS_VERSION = "57.4.0"
93a1c0
+_wheels = {}
93a1c0
 
ac4541
-_PIP_VERSION = "21.2.3"
93a1c0
+def _get_most_recent_wheel_version(pkg):
93a1c0
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
93a1c0
+    _wheels[pkg] = {}
93a1c0
+    for suffix in "-py2.py3-none-any.whl", "-py3-none-any.whl":
93a1c0
+        pattern = "{}*{}".format(prefix, suffix)
93a1c0
+        for path in glob.glob(pattern):
93a1c0
+            version_str = path[len(prefix):-len(suffix)]
93a1c0
+            _wheels[pkg][version_str] = os.path.basename(path)
93a1c0
+    return str(max(_wheels[pkg], key=distutils.version.LooseVersion))
93a1c0
+
93a1c0
+
93a1c0
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
93a1c0
+
93a1c0
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
93a1c0
 
93a1c0
 _PROJECTS = [
93a1c0
     ("setuptools", _SETUPTOOLS_VERSION, "py3"),
93a1c0
@@ -105,13 +119,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
93a1c0
         # additional paths that need added to sys.path
93a1c0
         additional_paths = []
93a1c0
         for project, version, py_tag in _PROJECTS:
93a1c0
-            wheel_name = "{}-{}-{}-none-any.whl".format(project, version, py_tag)
93a1c0
-            whl = resources.read_binary(
93a1c0
-                _bundled,
93a1c0
-                wheel_name,
93a1c0
-            )
93a1c0
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
93a1c0
-                fp.write(whl)
93a1c0
+            wheel_name = _wheels[project][version]
93a1c0
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
93a1c0
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
93a1c0
+                    fp.write(sfp.read())
93a1c0
 
93a1c0
             additional_paths.append(os.path.join(tmpdir, wheel_name))
93a1c0