Merge pull request #11030 from uranusjr/build-env-req-check-evaluate-marker

This commit is contained in:
Tzu-ping Chung 2022-04-16 19:46:23 +08:00 committed by GitHub
commit 8133d83929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

2
news/10883.bugfix.rst Normal file
View File

@ -0,0 +1,2 @@
When checking for conflicts in the build environment, correctly skip requirements
containing markers that do not match the current environment.

View File

@ -175,6 +175,8 @@ class BuildEnvironment:
)
for req_str in reqs:
req = Requirement(req_str)
if req.marker is not None and not req.marker.evaluate():
continue # FIXME: Consider extras?
dist = env.get_distribution(req.name)
if not dist:
missing.add(req_str)

View File

@ -165,6 +165,25 @@ def test_build_env_requirements_check(script: PipTestEnvironment) -> None:
""",
)
run_with_build_env(
script,
"""
build_env.install_requirements(
finder,
["bar==3.0"],
"normal",
kind="installing bar in normal",
)
r = build_env.check_requirements(
[
"bar==2.0; python_version < '3.0'",
"bar==3.0; python_version >= '3.0'",
],
)
assert r == (set(), set()), repr(r)
""",
)
def test_build_env_overlay_prefix_has_priority(script: PipTestEnvironment) -> None:
create_basic_wheel_for_package(script, "pkg", "2.0")