|
|
1a5cfa |
From 36f1f2b4620b13bdc7ac1c349253ac07960c33b3 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
|
|
|
6551b0 |
---
|
|
|
1a5cfa |
Lib/ensurepip/__init__.py | 32 ++++++++++++++++++++++----------
|
|
|
1a5cfa |
1 file changed, 22 insertions(+), 10 deletions(-)
|
|
|
6551b0 |
|
|
|
6551b0 |
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
|
|
|
1a5cfa |
index 566fb2a096..47da08d3d5 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
|
|
|
1a5cfa |
@@ -8,10 +9,24 @@ import tempfile
|
|
|
6551b0 |
|
|
|
6551b0 |
__all__ = ["version", "bootstrap"]
|
|
|
6551b0 |
|
|
|
6551b0 |
+_WHEEL_DIR = "/usr/share/python38-wheels/"
|
|
|
6551b0 |
|
|
|
6551b0 |
-_SETUPTOOLS_VERSION = "41.2.0"
|
|
|
1a5cfa |
+_wheels = {}
|
|
|
6551b0 |
|
|
|
6551b0 |
-_PIP_VERSION = "19.2.3"
|
|
|
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")
|
|
|
6551b0 |
|
|
|
6551b0 |
_PROJECTS = [
|
|
|
6551b0 |
("setuptools", _SETUPTOOLS_VERSION),
|
|
|
1a5cfa |
@@ -105,13 +120,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
|
|
|
1a5cfa |
# additional paths that need added to sys.path
|
|
|
6551b0 |
additional_paths = []
|
|
|
6551b0 |
for project, version in _PROJECTS:
|
|
|
1a5cfa |
- wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
|
|
|
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 |
|
|
|
6551b0 |
--
|
|
|
1a5cfa |
2.26.2
|
|
|
6551b0 |
|