Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add all wheels option to pip download Fixes #4422 #4423

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pip/basecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -336,4 +336,5 @@ def _build_package_finder(self, options, session,
versions=python_versions,
abi=abi,
implementation=implementation,
all_wheels=all_wheels,
)
9 changes: 9 additions & 0 deletions pip/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 16 additions & 9 deletions pip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down