Skip to content

Commit

Permalink
Merge pull request #11124 from uranusjr/use-contain-for-checking
Browse files Browse the repository at this point in the history
Allow pre-release to satisfy build requirements
  • Loading branch information
pradyunsg authored May 16, 2022
2 parents 30af807 + f7c05a5 commit f20ab57
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions news/11123.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Allow using a pre-release version to satisfy a build requirement. This helps
manually populated build environments to more accurately detect build-time
requirement conflicts.
2 changes: 1 addition & 1 deletion src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def check_requirements(
installed_req_str = f"{req.name}=={dist.version}"
else:
installed_req_str = f"{req.name}==={dist.version}"
if dist.version not in req.specifier:
if not req.specifier.contains(dist.version, prereleases=True):
conflicting.add((installed_req_str, req_str))
# FIXME: Consider direct URL?
return conflicting, missing
Expand Down
27 changes: 26 additions & 1 deletion tests/functional/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

from pip._internal.build_env import BuildEnvironment
from pip._internal.req import InstallRequirement
from tests.lib import PipTestEnvironment, TestData, make_test_finder, path_to_url
from tests.lib import (
PipTestEnvironment,
TestData,
create_basic_wheel_for_package,
make_test_finder,
path_to_url,
)
from tests.lib.path import Path


Expand Down Expand Up @@ -232,6 +238,25 @@ def test_validate_conflicting_pep517_backend_requirements(
assert result.returncode != 0 and msg in result.stderr, str(result)


def test_pep517_backend_requirements_satisfied_by_prerelease(
script: PipTestEnvironment,
data: TestData,
) -> None:
create_basic_wheel_for_package(script, "myreq", "1.0a1")
script.pip("install", "myreq==1.0a1", "--no-index", "-f", script.scratch_path)
script.pip("install", "test_backend", "--no-index", "-f", data.backends)

project_dir = make_project(
script.temp_path,
requires=["test_backend", "myreq"],
backend="test_backend",
)
project_dir.joinpath("backend_reqs.txt").write_text("myreq")

result = script.pip("install", "--no-index", "--no-build-isolation", project_dir)
assert "Installing backend dependencies:" not in result.stdout


def test_pep517_backend_requirements_already_satisfied(
script: PipTestEnvironment, tmpdir: Path, data: TestData
) -> None:
Expand Down

0 comments on commit f20ab57

Please sign in to comment.