This commit is contained in:
Josh Cannon 2023-11-29 15:16:42 -07:00 committed by GitHub
commit 46380786c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

1
news/12216.bugfix.rst Normal file
View File

@ -0,0 +1 @@
Fix resolution to respect ``--python-version`` when checking ``Requires-Python``.

View File

@ -370,6 +370,7 @@ class InstallCommand(RequirementCommand):
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)

View File

@ -376,7 +376,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"
)
install_dir = tmpdir_factory.mktemp(package) / "install"
lib_install_dir = install_dir / "lib"
bin_install_dir = install_dir / "bin"

View File

@ -416,6 +416,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(
"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,