diff --git a/pip/req.py b/pip/req.py index e81f5a0c4a9..5742e62ce07 100644 --- a/pip/req.py +++ b/pip/req.py @@ -1102,6 +1102,13 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): for subreq in req_to_install.bundle_requirements(): reqs.append(subreq) self.add_requirement(subreq) + elif self.is_download: + req_to_install.source_dir = location + if not is_wheel: + # FIXME: see https://github.com/pypa/pip/issues/1112 + req_to_install.run_egg_info() + if url and url.scheme in vcs.all_schemes: + req_to_install.archive(self.download_dir) elif is_wheel: req_to_install.source_dir = location req_to_install.url = url.url @@ -1117,11 +1124,6 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): req_to_install) reqs.append(subreq) self.add_requirement(subreq) - elif self.is_download: - req_to_install.source_dir = location - req_to_install.run_egg_info() - if url and url.scheme in vcs.all_schemes: - req_to_install.archive(self.download_dir) else: req_to_install.source_dir = location req_to_install.run_egg_info() diff --git a/tests/functional/test_install_download.py b/tests/functional/test_install_download.py index 9132485aaab..0861a728347 100644 --- a/tests/functional/test_install_download.py +++ b/tests/functional/test_install_download.py @@ -15,6 +15,21 @@ def test_download_if_requested(): assert env.site_packages/ 'initools' not in result.files_created +def test_download_wheel(): + """ + Test using "pip install --download" to download a *.whl archive. + FIXME: this test could use a local --find-links dir, but -d with local + --find-links has a bug https://github.com/pypa/pip/issues/1111 + """ + + env = reset_env() + result = run_pip('install', '--use-wheel', + '-f', 'https://bitbucket.org/pypa/pip-test-package/downloads', + '-d', '.', 'pip-test-package') + assert Path('scratch')/ 'pip_test_package-0.1.1-py2.py3-none-any.whl' in result.files_created + assert env.site_packages/ 'piptestpackage' not in result.files_created + + def test_single_download_from_requirements_file(): """ It should support download (in the scratch path) from PyPi from a requirements file