Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax check_dist_restriction for dry run #11765

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/11764.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Relax ``check_dist_restriction`` for dry run so one can more easily use ``pip`` as a cross platform
dependency resolver.
5 changes: 5 additions & 0 deletions src/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def check_dist_restriction(options: Values, check_target: bool = False) -> None:
options.format_control != binary_only and not options.ignore_dependencies
)

if getattr(options, "dry_run", False):
# In dry run mode nothing will be downloaded or installed, so sdist are OK and
# there is no need to specify `--target`.
return

# Installations or downloads using dist restrictions must not combine
# source distributions and dist-specific wheels, as they are not
# guaranteed to be locally compatible.
Expand Down
17 changes: 17 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,23 @@ def test_install_dry_run(script: PipTestEnvironment, data: TestData) -> None:
assert "Successfully installed" not in result.stdout


def test_install_dry_run_with_dist_restriction(
script: PipTestEnvironment, data: TestData
) -> None:
"""Test that pip install --dry-run logs what it would install."""
result = script.pip(
"install",
"--dry-run",
"--platform",
"linux_x86_64",
"--find-links",
data.find_links,
"simple",
)
assert "Would install simple-3.0" in result.stdout
assert "Successfully installed" not in result.stdout


def test_install_8559_missing_wheel_package(
script: PipTestEnvironment, shared_data: TestData
) -> None:
Expand Down