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