Skip to content

Commit 89d50dd

Browse files
authored
Merge pull request #9305 from nikitos3000/pip-download-ignore-requires-python
Add `--ignore-requires-python` support to pip download.
2 parents 7abd8bd + f8b03ee commit 89d50dd

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

news/1884.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``--ignore-requires-python`` support to pip download.

src/pip/_internal/commands/download.py

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def add_options(self):
5656
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
5757
self.cmd_opts.add_option(cmdoptions.use_pep517())
5858
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
59+
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
5960

6061
self.cmd_opts.add_option(
6162
'-d', '--dest', '--destination-dir', '--destination-directory',
@@ -96,6 +97,7 @@ def run(self, options, args):
9697
options=options,
9798
session=session,
9899
target_python=target_python,
100+
ignore_requires_python=options.ignore_requires_python,
99101
)
100102

101103
req_tracker = self.enter_context(get_requirement_tracker())
@@ -122,6 +124,7 @@ def run(self, options, args):
122124
preparer=preparer,
123125
finder=finder,
124126
options=options,
127+
ignore_requires_python=options.ignore_requires_python,
125128
py_version_info=options.python_version,
126129
)
127130

tests/functional/test_download.py

+28
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,34 @@ def make_args(python_version):
530530
script.pip(*args) # no exception
531531

532532

533+
def test_download_ignore_requires_python_dont_fail_with_wrong_python(
534+
script,
535+
with_wheel,
536+
):
537+
"""
538+
Test that --ignore-requires-python ignores Requires-Python check.
539+
"""
540+
wheel_path = make_wheel_with_python_requires(
541+
script,
542+
"mypackage",
543+
python_requires="==999",
544+
)
545+
wheel_dir = os.path.dirname(wheel_path)
546+
547+
result = script.pip(
548+
"download",
549+
"--ignore-requires-python",
550+
"--no-index",
551+
"--find-links",
552+
wheel_dir,
553+
"--only-binary=:all:",
554+
"--dest",
555+
".",
556+
"mypackage==1.0",
557+
)
558+
result.did_create(Path('scratch') / 'mypackage-1.0-py2.py3-none-any.whl')
559+
560+
533561
def test_download_specify_abi(script, data):
534562
"""
535563
Test using "pip download --abi" to download a .whl archive

0 commit comments

Comments
 (0)