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

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