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

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