Skip to content
Merged
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
1 change: 1 addition & 0 deletions news/12216.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix resolution to respect ``--python-version`` when checking ``Requires-Python``.
1 change: 1 addition & 0 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def run(self, options: Values, args: List[str]) -> int:
force_reinstall=options.force_reinstall,
upgrade_strategy=upgrade_strategy,
use_pep517=options.use_pep517,
py_version_info=options.python_version,
)

self.trace_basic_info(finder)
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,10 @@ def _common_wheel_editable_install(
tmpdir_factory: pytest.TempPathFactory, common_wheels: Path, package: str
) -> Path:
wheel_candidates = list(common_wheels.glob(f"{package}-*.whl"))
assert len(wheel_candidates) == 1, wheel_candidates
assert len(wheel_candidates) == 1, (
f"Missing wheels in {common_wheels}, expected 1 got '{wheel_candidates}'."
" Are you running the tests via nox? See https://pip.pypa.io/en/latest/development/getting-started/#running-tests"
)
Comment on lines +382 to +385
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by improvement, because my dumb self was trying to run pytest and didn't read the docs 😅

install_dir = tmpdir_factory.mktemp(package) / "install"
lib_install_dir = install_dir / "lib"
bin_install_dir = install_dir / "bin"
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,30 @@ def test_new_resolver_requires_python_error(script: PipTestEnvironment) -> None:
assert message in result.stderr, str(result)


def test_new_resolver_requires_python_ok_with_python_version_flag(
script: PipTestEnvironment,
) -> None:
create_basic_wheel_for_package(
script,
"base",
"0.1.0",
requires_python="<3",
)
result = script.pip(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently fails due to #12215, once #12217 is in, I'll merge main back into this branch.

"install",
"--no-cache-dir",
"--no-index",
"--find-links",
script.scratch_path,
"--dry-run",
"--python-version=2",
"--only-binary=:all:",
"base",
)

assert not result.stderr, str(result)


def test_new_resolver_installed(script: PipTestEnvironment) -> None:
create_basic_wheel_for_package(
script,
Expand Down