From 89f49d3590f93a582ead506cd4795cdf5984076c Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 6 Apr 2017 15:22:48 +0100 Subject: [PATCH] add all wheels option to pip download Fixes #4422 --- pip/basecommand.py | 3 ++- pip/commands/download.py | 9 +++++++++ pip/index.py | 25 ++++++++++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/pip/basecommand.py b/pip/basecommand.py index 2c17c92c689..39a0d502c07 100644 --- a/pip/basecommand.py +++ b/pip/basecommand.py @@ -315,7 +315,7 @@ def populate_requirement_set(requirement_set, args, options, finder, def _build_package_finder(self, options, session, platform=None, python_versions=None, - abi=None, implementation=None): + abi=None, implementation=None, all_wheels=False): """ Create a package finder appropriate to this requirement command. """ @@ -336,4 +336,5 @@ def _build_package_finder(self, options, session, versions=python_versions, abi=abi, implementation=implementation, + all_wheels=all_wheels, ) diff --git a/pip/commands/download.py b/pip/commands/download.py index 26b6e5f2ed9..eb78fcecdfd 100644 --- a/pip/commands/download.py +++ b/pip/commands/download.py @@ -112,6 +112,15 @@ def __init__(self, *args, **kw): "this option."), ) + cmd_opts.add_option( + '--all-wheels', + dest='all_wheels', + action='store_true', + default=False, + help=("Download all wheels available, ignores --platform, " + "--python-version, --implementation and --abi"), + ) + index_opts = cmdoptions.make_option_group( cmdoptions.index_group, self.parser, diff --git a/pip/index.py b/pip/index.py index bfbe5d7828a..876cde2922e 100644 --- a/pip/index.py +++ b/pip/index.py @@ -108,7 +108,8 @@ class PackageFinder(object): def __init__(self, find_links, index_urls, allow_all_prereleases=False, trusted_hosts=None, process_dependency_links=False, session=None, format_control=None, platform=None, - versions=None, abi=None, implementation=None): + versions=None, abi=None, implementation=None, + all_wheels=False): """Create a PackageFinder. :param format_control: A FormatControl object or None. Used to control @@ -169,12 +170,15 @@ def __init__(self, find_links, index_urls, allow_all_prereleases=False, self.session = session # The valid tags to check potential found wheel candidates against - self.valid_tags = get_supported( - versions=versions, - platform=platform, - abi=abi, - impl=implementation, - ) + self._all_wheels = all_wheels + self.valid_tags = [] + if not self._all_wheels: + self.valid_tags = get_supported( + versions=versions, + platform=platform, + abi=abi, + impl=implementation, + ) # If we don't have TLS enabled, then WARN if anyplace we're looking # relies on TLS. @@ -252,6 +256,9 @@ def sort_path(path): return files, urls + def _supported(self, wheel): + return self._all_wheels or wheel.supported(self.valid_tags) + def _candidate_sort_key(self, candidate): """ Function used to generate link sort key for link tuples. @@ -269,7 +276,7 @@ def _candidate_sort_key(self, candidate): if candidate.location.is_wheel: # can raise InvalidWheelFilename wheel = Wheel(candidate.location.filename) - if not wheel.supported(self.valid_tags): + if not self._supported(wheel): raise UnsupportedWheel( "%s is not a supported wheel for this platform. It " "can't be sorted." % wheel.filename @@ -635,7 +642,7 @@ def _link_package_versions(self, link, search): link, 'wrong project name (not %s)' % search.supplied) return - if not wheel.supported(self.valid_tags): + if not self._supported(wheel): self._log_skipped_link( link, 'it is not compatible with this Python') return