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

8f0bcc
From 2c91575950d4de95d308e30cc4ab20d032b1aceb 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
---
8f0bcc
 Lib/ensurepip/__init__.py | 37 ++++++++++++++++++++++++++-----------
8f0bcc
 1 file changed, 26 insertions(+), 11 deletions(-)
93c559
93c559
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
8f0bcc
index e510cc7..8de2e55 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
8f0bcc
@@ -6,13 +8,29 @@ import tempfile
93c559
 import subprocess
93c559
 from importlib import resources
93c559
 
93c559
-from . import _bundled
93c559
-
93c559
 
93c559
 
93c559
 __all__ = ["version", "bootstrap"]
8f0bcc
-_SETUPTOOLS_VERSION = "58.1.0"
8f0bcc
-_PIP_VERSION = "22.0.4"
8f0bcc
+
93c559
+_WHEEL_DIR = "/usr/share/python39-wheels/"
8f0bcc
+
93c559
+_wheels = {}
8f0bcc
+
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")
8f0bcc
+
93c559
 _PROJECTS = [
93c559
     ("setuptools", _SETUPTOOLS_VERSION, "py3"),
8f0bcc
     ("pip", _PIP_VERSION, "py3"),
8f0bcc
@@ -101,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
 
8f0bcc
-- 
8f0bcc
2.35.3
8f0bcc