Merge pull request #12217 from thejcannon/jcannon/issue12215

This commit is contained in:
Tzu-ping Chung 2023-09-06 15:28:46 +08:00 committed by GitHub
commit 7c8425b8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 2 deletions

1
news/12215.feature.rst Normal file
View File

@ -0,0 +1 @@
Allow ``pip install --dry-run`` to use platform and ABI overriding options similar to ``--target``.

View File

@ -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'"
)

View File

@ -2541,6 +2541,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:
"""