diff options
author | Marcus Smith <qwcode@gmail.com> | 2014-02-02 15:09:32 -0800 |
---|---|---|
committer | Marcus Smith <qwcode@gmail.com> | 2014-02-08 09:17:13 -0800 |
commit | 85d68bbf97307b4038328c8e9b079553a61cf867 (patch) | |
tree | 81455ddf242c37ec53a2359923bcfdc260147087 | |
parent | a25b3d15c241789384154252a674b17e4196ef7f (diff) | |
download | pip-85d68bbf97307b4038328c8e9b079553a61cf867.tar.gz |
fixes for downloading wheels (Issue #1112)
Conflicts:
pip/req/req_set.py
-rw-r--r-- | pip/req.py | 43 | ||||
-rw-r--r-- | tests/data/packages/colander-0.9.9-py2.py3-none-any.whl | bin | 0 -> 83733 bytes | |||
-rw-r--r-- | tests/data/packages/translationstring-1.1.tar.gz | bin | 0 -> 28524 bytes | |||
-rw-r--r-- | tests/functional/test_install_download.py | 29 |
4 files changed, 56 insertions, 16 deletions
diff --git a/pip/req.py b/pip/req.py index a152c5eb9..91d3301f7 100644 --- a/pip/req.py +++ b/pip/req.py @@ -1217,18 +1217,6 @@ class RequirementSet(object): 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() @@ -1258,7 +1246,26 @@ class RequirementSet(object): req_to_install ) install = False - if not (is_bundle or is_wheel): + 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) + + # sdists + elif not is_bundle: ## FIXME: shouldn't be globally added: finder.add_dependency_links(req_to_install.dependency_links) if (req_to_install.extras): @@ -1281,10 +1288,14 @@ class RequirementSet(object): 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: + + # 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) - else: - self.reqs_to_cleanup.append(req_to_install) if install: self.successfully_downloaded.append(req_to_install) 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 Binary files differnew file mode 100644 index 000000000..031718f9c --- /dev/null +++ b/tests/data/packages/colander-0.9.9-py2.py3-none-any.whl diff --git a/tests/data/packages/translationstring-1.1.tar.gz b/tests/data/packages/translationstring-1.1.tar.gz Binary files differnew file mode 100644 index 000000000..25370b8f9 --- /dev/null +++ b/tests/data/packages/translationstring-1.1.tar.gz diff --git a/tests/functional/test_install_download.py b/tests/functional/test_install_download.py index 03ca24135..dd2f8f602 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 @@ -48,6 +49,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 |