Skip to content
Merged
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
1 change: 1 addition & 0 deletions news/1884.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``--ignore-requires-python`` support to pip download.
3 changes: 3 additions & 0 deletions src/pip/_internal/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def add_options(self):
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
self.cmd_opts.add_option(cmdoptions.use_pep517())
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())

self.cmd_opts.add_option(
'-d', '--dest', '--destination-dir', '--destination-directory',
Expand Down Expand Up @@ -96,6 +97,7 @@ def run(self, options, args):
options=options,
session=session,
target_python=target_python,
ignore_requires_python=options.ignore_requires_python,
)

req_tracker = self.enter_context(get_requirement_tracker())
Expand All @@ -122,6 +124,7 @@ def run(self, options, args):
preparer=preparer,
finder=finder,
options=options,
ignore_requires_python=options.ignore_requires_python,
py_version_info=options.python_version,
)

Expand Down
28 changes: 28 additions & 0 deletions tests/functional/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,34 @@ def make_args(python_version):
script.pip(*args) # no exception


def test_download_ignore_requires_python_dont_fail_with_wrong_python(
script,
with_wheel,
):
"""
Test that --ignore-requires-python ignores Requires-Python check.
"""
wheel_path = make_wheel_with_python_requires(
script,
"mypackage",
python_requires="==999",
)
wheel_dir = os.path.dirname(wheel_path)

result = script.pip(
"download",
"--ignore-requires-python",
"--no-index",
"--find-links",
wheel_dir,
"--only-binary=:all:",
"--dest",
".",
"mypackage==1.0",
)
result.did_create(Path('scratch') / 'mypackage-1.0-py2.py3-none-any.whl')


def test_download_specify_abi(script, data):
"""
Test using "pip download --abi" to download a .whl archive
Expand Down