From b2a151500b1e827de3ca950881204e4f4c9df08a Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 8 Aug 2023 13:37:57 -0500 Subject: [PATCH 1/4] --dry-run is cool --- src/pip/_internal/cli/cmdoptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 02ba60827..64bc59bbd 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -92,10 +92,10 @@ def check_dist_restriction(options: Values, check_target: bool = False) -> None: ) if check_target: - if dist_restriction_set and not options.target_dir: + if not options.dry_run and dist_restriction_set and not options.target_dir: raise CommandError( "Can not use any platform or abi specific options unless " - "installing via '--target'" + "installing via '--target' or using '--dry-run'" ) From 38126ce5f811f98c2f45fcbfad47f3d5538120fe Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 8 Aug 2023 13:42:11 -0500 Subject: [PATCH 2/4] HEAR YE HEAR YE --- news/12215.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/12215.bugfix.rst diff --git a/news/12215.bugfix.rst b/news/12215.bugfix.rst new file mode 100644 index 000000000..f814540ff --- /dev/null +++ b/news/12215.bugfix.rst @@ -0,0 +1 @@ +Fix unnecessary error when using ``--dry-run`` and ``--python-version`` without ``--target`` From 864139adb0819053e76a3db4c50e916ef79cfc8c Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 8 Aug 2023 14:32:59 -0500 Subject: [PATCH 3/4] add tests --- tests/functional/test_install.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index eabddfe58..038683246 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -2459,6 +2459,40 @@ def test_install_pip_prints_req_chain_local(script: PipTestEnvironment) -> None: ) +def test_install_dist_restriction_without_target(script: PipTestEnvironment) -> None: + result = script.pip( + "install", "--python-version=3.1", "--only-binary=:all:", expect_error=True + ) + assert ( + "Can not use any platform or abi specific options unless installing " + "via '--target'" in result.stderr + ), str(result) + + +def test_install_dist_restriction_dry_run_doesnt_require_target( + script: PipTestEnvironment, +) -> None: + create_basic_wheel_for_package( + script, + "base", + "0.1.0", + ) + + result = script.pip( + "install", + "--python-version=3.1", + "--only-binary=:all:", + "--dry-run", + "--no-cache-dir", + "--no-index", + "--find-links", + script.scratch_path, + "base", + ) + + assert not result.stderr, str(result) + + @pytest.mark.network def test_install_pip_prints_req_chain_pypi(script: PipTestEnvironment) -> None: """ From 46754f1580d46aaa11147796336cd79ea1682caa Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 9 Aug 2023 09:04:26 -0500 Subject: [PATCH 4/4] It's not a bug(fix) it's a FEATURE --- news/12215.bugfix.rst | 1 - news/12215.feature.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 news/12215.bugfix.rst create mode 100644 news/12215.feature.rst diff --git a/news/12215.bugfix.rst b/news/12215.bugfix.rst deleted file mode 100644 index f814540ff..000000000 --- a/news/12215.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix unnecessary error when using ``--dry-run`` and ``--python-version`` without ``--target`` diff --git a/news/12215.feature.rst b/news/12215.feature.rst new file mode 100644 index 000000000..407dc903e --- /dev/null +++ b/news/12215.feature.rst @@ -0,0 +1 @@ +Allow ``pip install --dry-run`` to use platform and ABI overriding options similar to ``--target``.