From f8b03eefe20b3102e23b8934bbfda87903109883 Mon Sep 17 00:00:00 2001 From: Nikita Chepanov Date: Tue, 15 Dec 2020 16:57:55 -0500 Subject: [PATCH] Add `--ignore-requires-python` support to pip download --- news/1884.feature.rst | 1 + src/pip/_internal/commands/download.py | 3 +++ tests/functional/test_download.py | 28 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 news/1884.feature.rst diff --git a/news/1884.feature.rst b/news/1884.feature.rst new file mode 100644 index 00000000000..4b0b4180c35 --- /dev/null +++ b/news/1884.feature.rst @@ -0,0 +1 @@ +Add ``--ignore-requires-python`` support to pip download. diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py index 7405870aefc..7509397240b 100644 --- a/src/pip/_internal/commands/download.py +++ b/src/pip/_internal/commands/download.py @@ -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', @@ -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()) @@ -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, ) diff --git a/tests/functional/test_download.py b/tests/functional/test_download.py index 8a816b63b44..24bc4ddbcc9 100644 --- a/tests/functional/test_download.py +++ b/tests/functional/test_download.py @@ -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