This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ensurepip patch that enables rewheel
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
diff -r 15a6be05e970 Lib/ensurepip/__init__.py | ||
--- a/Lib/ensurepip/__init__.py Tue Feb 11 11:54:08 2014 +0100 | ||
+++ b/Lib/ensurepip/__init__.py Tue Feb 11 12:42:44 2014 +0100 | ||
@@ -1,8 +1,10 @@ | ||
import os | ||
import os.path | ||
import pkgutil | ||
+import shutil | ||
import sys | ||
import tempfile | ||
+from ensurepip import rewheel | ||
|
||
|
||
__all__ = ["version", "bootstrap"] | ||
@@ -38,6 +40,7 @@ | ||
|
||
# Install the bundled software | ||
import pip | ||
+ args.append('--pre') | ||
pip.main(args) | ||
|
||
|
||
@@ -87,20 +90,40 @@ | ||
# 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.TemporaryDirectory() | ||
+ for dr in dep_records: | ||
+ new_whl = rewheel.rewheel_from_record(dr, rewheel_dir.name) | ||
+ whls.append(os.path.join(rewheel_dir.name, 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__), | ||
+ "ensurepip", | ||
+ "bundled", | ||
+ "{}-{}-py2.py3-none-any.whl".format(project, version) | ||
+ ) | ||
+ whls.append(whl) | ||
+ | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
# 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: | ||
+ rewheel_dir.cleanup() | ||
|
||
# Construct the arguments to be passed to the pip command | ||
args = ["install", "--no-index", "--find-links", tmpdir] |