Skip to content

Skip conditional build req without matching marker #11030

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

Merged
merged 1 commit into from
Apr 16, 2022
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
2 changes: 2 additions & 0 deletions news/10883.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
When checking for conflicts in the build environment, correctly skip requirements
containing markers that do not match the current environment.
2 changes: 2 additions & 0 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def check_requirements(
)
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)
Expand Down
19 changes: 19 additions & 0 deletions tests/functional/test_build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down