This repository was archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpython2-ensurepip-rewheel.patch
104 lines (91 loc) · 3.91 KB
/
python2-ensurepip-rewheel.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
diff -Nur Python-2.7.9/Lib/ensurepip/__init__.py Python-2.7.9-rewheel/Lib/ensurepip/__init__.py
--- Python-2.7.9/Lib/ensurepip/__init__.py 2014-08-21 10:49:30.792695824 +0200
+++ Python-2.7.9-rewheel/Lib/ensurepip/__init__.py 2014-08-21 10:10:41.958341726 +0200
@@ -7,6 +7,7 @@ import pkgutil
import shutil
import sys
import tempfile
+from ensurepip import rewheel
__all__ = ["version", "bootstrap"]
@@ -43,6 +44,8 @@
# Install the bundled software
import pip
+ if args[0] in ["install", "list", "wheel"]:
+ args.append('--pre')
pip.main(args)
@@ -93,21 +96,40 @@ def bootstrap(root=None, upgrade=False,
# omit pip and easy_install
os.environ["ENSUREPIP_OPTIONS"] = "install"
+ whls = []
+ rewheel_dir = None
+ # try to see if we have system-wide versions of _PROJECTS
+ dep_records = rewheel.find_system_records([p[0] for p in _PROJECTS])
+ # TODO: check if system-wide versions are the newest ones
+ # if --upgrade is used?
+ if all(dep_records):
+ # if we have all _PROJECTS installed system-wide, we'll recreate
+ # wheels from them and install those
+ rewheel_dir = tempfile.mkdtemp()
+ for dr in dep_records:
+ new_whl = rewheel.rewheel_from_record(dr, rewheel_dir)
+ whls.append(os.path.join(rewheel_dir, new_whl))
+ else:
+ # if we don't have all the _PROJECTS installed system-wide,
+ # let's just fall back to bundled wheels
+ for project, version in _PROJECTS:
+ whl = os.path.join(
+ os.path.dirname(__file__),
+ "_bundled",
+ "{}-{}-py2.py3-none-any.whl".format(project, version)
+ )
+ whls.append(whl)
+
tmpdir = tempfile.mkdtemp()
try:
# Put our bundled wheels into a temporary directory and construct the
# additional paths that need added to sys.path
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)
-
- additional_paths.append(os.path.join(tmpdir, wheel_name))
+ for whl in whls:
+ shutil.copy(whl, tmpdir)
+ additional_paths.append(os.path.join(tmpdir, os.path.basename(whl)))
+ if rewheel_dir:
+ shutil.rmtree(rewheel_dir)
# Construct the arguments to be passed to the pip command
args = ["install", "--no-index", "--find-links", tmpdir]
diff -Nur Python-2.7.9/Makefile.pre.in Python-2.7.9-rewheel/Makefile.pre.in
--- Python-2.7.9/Makefile.pre.in 2014-08-21 10:49:31.512695040 +0200
+++ Python-2.7.9-rewheel/Makefile.pre.in 2014-08-21 10:10:41.961341722 +0200
@@ -976,7 +976,7 @@ LIBSUBDIRS= lib-tk lib-tk/test lib-tk/te
test/tracedmodules \
encodings compiler hotshot \
email email/mime email/test email/test/data \
- ensurepip ensurepip/_bundled \
+ ensurepip ensurepip/_bundled ensurepip/rewheel\
json json/tests \
sqlite3 sqlite3/test \
logging bsddb bsddb/test csv importlib wsgiref \
diff -up Python-2.7.9/Lib/ensurepip/__init__.py.ensure Python-2.7.9/Lib/ensurepip/__init__.py
--- Python-2.7.9/Lib/ensurepip/__init__.py.ensure 2015-03-05 11:36:58.509976288 +0100
+++ Python-2.7.9/Lib/ensurepip/__init__.py 2015-03-05 11:38:48.362054753 +0100
@@ -9,13 +9,15 @@ import sys
import tempfile
from ensurepip import rewheel
+import setuptools
+import pip
__all__ = ["version", "bootstrap"]
-_SETUPTOOLS_VERSION = "7.0"
+_SETUPTOOLS_VERSION = setuptools.version.__version__
-_PIP_VERSION = "1.5.6"
+_PIP_VERSION = pip.__version__
# pip currently requires ssl support, so we try to provide a nicer
# error message when that is missing (http://bugs.python.org/issue19744)