|
|
341bcbc |
From b81c3b618760bd400dbcec7ac945a1f42bd4268b Mon Sep 17 00:00:00 2001
|
|
|
285f554 |
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
|
|
285f554 |
Date: Wed, 15 Aug 2018 15:36:29 +0200
|
|
|
29530ba |
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
|
|
|
285f554 |
|
|
|
285f554 |
We keep them in /usr/share/python-wheels
|
|
|
285f554 |
---
|
|
Marcel Plch |
1206bb9 |
Lib/ensurepip/__init__.py | 33 ++++++++++++++++++++++-----------
|
|
Marcel Plch |
1206bb9 |
1 file changed, 22 insertions(+), 11 deletions(-)
|
|
|
285f554 |
|
|
|
0b241ab |
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
|
|
|
b89d4ad |
index 545fce656f..f86992c90c 100644
|
|
|
0b241ab |
--- a/Lib/ensurepip/__init__.py
|
|
|
0b241ab |
+++ b/Lib/ensurepip/__init__.py
|
|
|
b89d4ad |
@@ -1,3 +1,5 @@
|
|
|
0b241ab |
+import distutils.version
|
|
|
0b241ab |
+import glob
|
|
|
0b241ab |
import os
|
|
|
0b241ab |
import os.path
|
|
|
0b241ab |
import sys
|
|
|
b89d4ad |
@@ -5,16 +7,28 @@ import runpy
|
|
|
1a985bb |
import tempfile
|
|
|
1a985bb |
from importlib import resources
|
|
|
0b241ab |
|
|
|
1a985bb |
-from . import _bundled
|
|
|
1a985bb |
-
|
|
|
0b241ab |
|
|
|
0b241ab |
|
|
|
1a985bb |
__all__ = ["version", "bootstrap"]
|
|
|
0b241ab |
|
|
|
1a985bb |
+_WHEEL_DIR = "/usr/share/python-wheels/"
|
|
|
1a985bb |
+
|
|
|
088c30c |
+_wheels = {}
|
|
|
1a985bb |
+
|
|
|
0b241ab |
+def _get_most_recent_wheel_version(pkg):
|
|
|
0b241ab |
+ prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
|
|
|
088c30c |
+ _wheels[pkg] = {}
|
|
|
088c30c |
+ for suffix in "-py2.py3-none-any.whl", "-py3-none-any.whl":
|
|
|
088c30c |
+ pattern = "{}*{}".format(prefix, suffix)
|
|
|
088c30c |
+ for path in glob.glob(pattern):
|
|
|
088c30c |
+ version_str = path[len(prefix):-len(suffix)]
|
|
|
088c30c |
+ _wheels[pkg][version_str] = os.path.basename(path)
|
|
|
088c30c |
+ return str(max(_wheels[pkg], key=distutils.version.LooseVersion))
|
|
|
0b241ab |
+
|
|
|
1a985bb |
|
|
|
1a985bb |
-_SETUPTOOLS_VERSION = "41.2.0"
|
|
|
0b241ab |
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
|
|
|
1a985bb |
|
|
|
1a985bb |
-_PIP_VERSION = "19.2.3"
|
|
|
0b241ab |
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
|
|
|
0b241ab |
|
|
|
0b241ab |
_PROJECTS = [
|
|
|
0b241ab |
("setuptools", _SETUPTOOLS_VERSION),
|
|
|
b89d4ad |
@@ -108,13 +122,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
|
|
|
088c30c |
# additional paths that need added to sys.path
|
|
|
0b241ab |
additional_paths = []
|
|
|
0b241ab |
for project, version in _PROJECTS:
|
|
|
088c30c |
- wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
|
|
|
b180b30 |
- whl = resources.read_binary(
|
|
|
b180b30 |
- _bundled,
|
|
|
b180b30 |
- wheel_name,
|
|
|
0b241ab |
- )
|
|
|
0b241ab |
- with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
|
|
|
0b241ab |
- fp.write(whl)
|
|
|
088c30c |
+ wheel_name = _wheels[project][version]
|
|
|
0b241ab |
+ with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
|
|
|
0b241ab |
+ with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
|
|
|
0b241ab |
+ fp.write(sfp.read())
|
|
|
0b241ab |
|
|
|
0b241ab |
additional_paths.append(os.path.join(tmpdir, wheel_name))
|
|
|
0b241ab |
|
|
|
285f554 |
--
|
|
|
341bcbc |
2.26.2
|
|
|
285f554 |
|