Skip to content

Commit

Permalink
Merge pull request #1527 from qwcode/wheel_deps
Browse files Browse the repository at this point in the history
fixes for downloading wheels (Issue #1112)
  • Loading branch information
qwcode committed Feb 2, 2014
2 parents 386d1b9 + 4af1008 commit 3311a44
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 30 deletions.
60 changes: 30 additions & 30 deletions pip/req/req_set.py
Expand Up @@ -381,30 +381,9 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
req_to_install.run_egg_info() req_to_install.run_egg_info()
if url and url.scheme in vcs.all_schemes: if url and url.scheme in vcs.all_schemes:
req_to_install.archive(self.download_dir) req_to_install.archive(self.download_dir)

##############################
## parse wheel dependencies ##
##############################

elif is_wheel: elif is_wheel:
req_to_install.source_dir = location req_to_install.source_dir = location
req_to_install.url = url.url 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: else:
req_to_install.source_dir = location req_to_install.source_dir = location
req_to_install.run_egg_info() req_to_install.run_egg_info()
Expand Down Expand Up @@ -444,11 +423,30 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
) )
install = 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: ## FIXME: shouldn't be globally added:
finder.add_dependency_links( finder.add_dependency_links(
req_to_install.dependency_links req_to_install.dependency_links
Expand Down Expand Up @@ -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): if not self.has_requirement(req_to_install.name):
#'unnamed' requirements will get added here #'unnamed' requirements will get added here
self.add_requirement(req_to_install) 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: if install:
self.successfully_downloaded.append(req_to_install) self.successfully_downloaded.append(req_to_install)
if (bundle if (bundle
Expand Down
Binary file not shown.
Binary file added tests/data/packages/translationstring-1.1.tar.gz
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/functional/test_install_download.py
@@ -1,3 +1,4 @@
import os
import textwrap import textwrap


from tests.lib.path import Path from tests.lib.path import Path
Expand Down Expand Up @@ -63,6 +64,34 @@ def test_download_should_download_dependencies(script):
assert script.site_packages / 'openid' not in result.files_created 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): def test_download_should_skip_existing_files(script):
""" """
It should not download files already existing in the scratch dir It should not download files already existing in the scratch dir
Expand Down

0 comments on commit 3311a44

Please sign in to comment.