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

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