diff --git a/pip/req/req_set.py b/pip/req/req_set.py index 3391e6f7d64..59e611ffb99 100644 --- a/pip/req/req_set.py +++ b/pip/req/req_set.py @@ -381,30 +381,9 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): req_to_install.run_egg_info() if url and url.scheme in vcs.all_schemes: req_to_install.archive(self.download_dir) - - ############################## - ## parse wheel dependencies ## - ############################## - elif is_wheel: req_to_install.source_dir = location req_to_install.url = url.url - dist = list( - pkg_resources.find_distributions(location) - )[0] - if not req_to_install.req: - req_to_install.req = dist.as_requirement() - self.add_requirement(req_to_install) - if not self.ignore_dependencies: - for subreq in dist.requires( - req_to_install.extras): - if self.has_requirement( - subreq.project_name): - continue - subreq = InstallRequirement(str(subreq), - req_to_install) - reqs.append(subreq) - self.add_requirement(subreq) else: req_to_install.source_dir = location req_to_install.run_egg_info() @@ -444,11 +423,30 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): ) install = False - ############################## - ## parse sdist dependencies ## - ############################## + ######################## + ## parse dependencies ## + ######################## + + if is_wheel: + dist = list( + pkg_resources.find_distributions(location) + )[0] + if not req_to_install.req: + req_to_install.req = dist.as_requirement() + self.add_requirement(req_to_install) + if not self.ignore_dependencies: + for subreq in dist.requires( + req_to_install.extras): + if self.has_requirement( + subreq.project_name): + continue + subreq = InstallRequirement(str(subreq), + req_to_install) + reqs.append(subreq) + self.add_requirement(subreq) - if not (is_bundle or is_wheel): + # sdists + elif not is_bundle: ## FIXME: shouldn't be globally added: finder.add_dependency_links( req_to_install.dependency_links @@ -482,12 +480,14 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): if not self.has_requirement(req_to_install.name): #'unnamed' requirements will get added here self.add_requirement(req_to_install) - if (self.is_download - or req_to_install._temp_build_dir is not None): - self.reqs_to_cleanup.append(req_to_install) - else: - self.reqs_to_cleanup.append(req_to_install) + # cleanup tmp src + if not is_bundle: + if ( + self.is_download or + req_to_install._temp_build_dir is not None + ): + self.reqs_to_cleanup.append(req_to_install) if install: self.successfully_downloaded.append(req_to_install) if (bundle diff --git a/tests/data/packages/colander-0.9.9-py2.py3-none-any.whl b/tests/data/packages/colander-0.9.9-py2.py3-none-any.whl new file mode 100644 index 00000000000..031718f9c37 Binary files /dev/null and b/tests/data/packages/colander-0.9.9-py2.py3-none-any.whl differ diff --git a/tests/data/packages/translationstring-1.1.tar.gz b/tests/data/packages/translationstring-1.1.tar.gz new file mode 100644 index 00000000000..25370b8f9ff Binary files /dev/null and b/tests/data/packages/translationstring-1.1.tar.gz differ diff --git a/tests/functional/test_install_download.py b/tests/functional/test_install_download.py index b6c4e9143e0..37fa260aea6 100644 --- a/tests/functional/test_install_download.py +++ b/tests/functional/test_install_download.py @@ -1,3 +1,4 @@ +import os import textwrap from tests.lib.path import Path @@ -63,6 +64,34 @@ def test_download_should_download_dependencies(script): assert script.site_packages / 'openid' not in result.files_created +def test_download_wheel_archive(script, data): + """ + It should download a wheel archive path + """ + wheel_filename = 'colander-0.9.9-py2.py3-none-any.whl' + wheel_path = os.path.join(data.find_links, wheel_filename) + result = script.pip( + 'install', wheel_path, + '-d', '.', '--no-deps' + ) + assert Path('scratch') / wheel_filename in result.files_created + + +def test_download_should_download_wheel_deps(script, data): + """ + It should download dependencies for wheels(in the scratch path) + """ + wheel_filename = 'colander-0.9.9-py2.py3-none-any.whl' + dep_filename = 'translationstring-1.1.tar.gz' + wheel_path = os.path.join(data.find_links, wheel_filename) + result = script.pip( + 'install', wheel_path, + '-d', '.', '--find-links', data.find_links, '--no-index' + ) + assert Path('scratch') / wheel_filename in result.files_created + assert Path('scratch') / dep_filename in result.files_created + + def test_download_should_skip_existing_files(script): """ It should not download files already existing in the scratch dir