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

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