72 lines
2.1 KiB
Diff
72 lines
2.1 KiB
Diff
diff --git a/lib-python/2.7/ensurepip/__init__.py b/lib-python/2.7/ensurepip/__init__.py
|
|
index c2abed8..bd1aa79 100644
|
|
--- a/lib-python/2.7/ensurepip/__init__.py
|
|
+++ b/lib-python/2.7/ensurepip/__init__.py
|
|
@@ -1,9 +1,10 @@
|
|
#!/usr/bin/env python2
|
|
from __future__ import print_function
|
|
|
|
+import distutils.version
|
|
+import glob
|
|
import os
|
|
import os.path
|
|
-import pkgutil
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
@@ -11,10 +12,20 @@ import tempfile
|
|
|
|
__all__ = ["version", "bootstrap"]
|
|
|
|
+_WHEEL_DIR = "/usr/share/python-wheels/"
|
|
|
|
-_SETUPTOOLS_VERSION = "28.8.0"
|
|
|
|
-_PIP_VERSION = "9.0.1"
|
|
+def _get_most_recent_wheel_version(pkg):
|
|
+ prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
|
|
+ suffix = "-py2.py3-none-any.whl"
|
|
+ pattern = "{}*{}".format(prefix, suffix)
|
|
+ versions = (p[len(prefix):-len(suffix)] for p in glob.glob(pattern))
|
|
+ return str(max(versions, key=distutils.version.LooseVersion))
|
|
+
|
|
+
|
|
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
|
|
+
|
|
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
|
|
|
|
_PROJECTS = [
|
|
("setuptools", _SETUPTOOLS_VERSION),
|
|
@@ -28,8 +39,13 @@ def _run_pip(args, additional_paths=None):
|
|
sys.path = additional_paths + sys.path
|
|
|
|
# Install the bundled software
|
|
- import pip
|
|
- pip.main(args)
|
|
+ try:
|
|
+ # pip 10
|
|
+ from pip._internal import main
|
|
+ except ImportError:
|
|
+ # pip 9
|
|
+ from pip import main
|
|
+ main(args)
|
|
|
|
|
|
def version():
|
|
@@ -85,12 +101,9 @@ def bootstrap(root=None, upgrade=False, user=False,
|
|
additional_paths = []
|
|
for project, version in _PROJECTS:
|
|
wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
|
|
- whl = pkgutil.get_data(
|
|
- "ensurepip",
|
|
- "_bundled/{}".format(wheel_name),
|
|
- )
|
|
- with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
|
|
- fp.write(whl)
|
|
+ with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
|
|
+ with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
|
|
+ fp.write(sfp.read())
|
|
|
|
additional_paths.append(os.path.join(tmpdir, wheel_name))
|
|
|