Skip to content

Commit 7c8425b

Browse files
authored
Merge pull request #12217 from thejcannon/jcannon/issue12215
2 parents d0115a5 + 46754f1 commit 7c8425b

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

news/12215.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow ``pip install --dry-run`` to use platform and ABI overriding options similar to ``--target``.

src/pip/_internal/cli/cmdoptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ def check_dist_restriction(options: Values, check_target: bool = False) -> None:
9292
)
9393

9494
if check_target:
95-
if dist_restriction_set and not options.target_dir:
95+
if not options.dry_run and dist_restriction_set and not options.target_dir:
9696
raise CommandError(
9797
"Can not use any platform or abi specific options unless "
98-
"installing via '--target'"
98+
"installing via '--target' or using '--dry-run'"
9999
)
100100

101101

tests/functional/test_install.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,6 +2541,40 @@ def test_install_pip_prints_req_chain_local(script: PipTestEnvironment) -> None:
25412541
)
25422542

25432543

2544+
def test_install_dist_restriction_without_target(script: PipTestEnvironment) -> None:
2545+
result = script.pip(
2546+
"install", "--python-version=3.1", "--only-binary=:all:", expect_error=True
2547+
)
2548+
assert (
2549+
"Can not use any platform or abi specific options unless installing "
2550+
"via '--target'" in result.stderr
2551+
), str(result)
2552+
2553+
2554+
def test_install_dist_restriction_dry_run_doesnt_require_target(
2555+
script: PipTestEnvironment,
2556+
) -> None:
2557+
create_basic_wheel_for_package(
2558+
script,
2559+
"base",
2560+
"0.1.0",
2561+
)
2562+
2563+
result = script.pip(
2564+
"install",
2565+
"--python-version=3.1",
2566+
"--only-binary=:all:",
2567+
"--dry-run",
2568+
"--no-cache-dir",
2569+
"--no-index",
2570+
"--find-links",
2571+
script.scratch_path,
2572+
"base",
2573+
)
2574+
2575+
assert not result.stderr, str(result)
2576+
2577+
25442578
@pytest.mark.network
25452579
def test_install_pip_prints_req_chain_pypi(script: PipTestEnvironment) -> None:
25462580
"""

0 commit comments

Comments
 (0)