Skip to content

Commit 4b1f064

Browse files
committed
Merge pull request #1113 from qwcode/fix_1106
let --download work with wheels
2 parents 901b46c + 5fcf4ab commit 4b1f064

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

pip/req.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,13 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
11021102
for subreq in req_to_install.bundle_requirements():
11031103
reqs.append(subreq)
11041104
self.add_requirement(subreq)
1105+
elif self.is_download:
1106+
req_to_install.source_dir = location
1107+
if not is_wheel:
1108+
# FIXME: see https://github.com/pypa/pip/issues/1112
1109+
req_to_install.run_egg_info()
1110+
if url and url.scheme in vcs.all_schemes:
1111+
req_to_install.archive(self.download_dir)
11051112
elif is_wheel:
11061113
req_to_install.source_dir = location
11071114
req_to_install.url = url.url
@@ -1117,11 +1124,6 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
11171124
req_to_install)
11181125
reqs.append(subreq)
11191126
self.add_requirement(subreq)
1120-
elif self.is_download:
1121-
req_to_install.source_dir = location
1122-
req_to_install.run_egg_info()
1123-
if url and url.scheme in vcs.all_schemes:
1124-
req_to_install.archive(self.download_dir)
11251127
else:
11261128
req_to_install.source_dir = location
11271129
req_to_install.run_egg_info()

tests/functional/test_install_download.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ def test_download_if_requested():
1515
assert env.site_packages/ 'initools' not in result.files_created
1616

1717

18+
def test_download_wheel():
19+
"""
20+
Test using "pip install --download" to download a *.whl archive.
21+
FIXME: this test could use a local --find-links dir, but -d with local
22+
--find-links has a bug https://github.com/pypa/pip/issues/1111
23+
"""
24+
25+
env = reset_env()
26+
result = run_pip('install', '--use-wheel',
27+
'-f', 'https://bitbucket.org/pypa/pip-test-package/downloads',
28+
'-d', '.', 'pip-test-package')
29+
assert Path('scratch')/ 'pip_test_package-0.1.1-py2.py3-none-any.whl' in result.files_created
30+
assert env.site_packages/ 'piptestpackage' not in result.files_created
31+
32+
1833
def test_single_download_from_requirements_file():
1934
"""
2035
It should support download (in the scratch path) from PyPi from a requirements file

0 commit comments

Comments
 (0)