Skip to content
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

Filter out build requirements that require an extra to be used #11112

Merged
merged 2 commits into from May 12, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions news/11112.bugfix.rst
@@ -0,0 +1 @@
Properly filter out optional dependencies (i.e. extras) when checking build environment distributions.
6 changes: 4 additions & 2 deletions src/pip/_internal/build_env.py
Expand Up @@ -175,8 +175,10 @@ 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?
# We're explicitly evaluating with an empty extra value, since build
# environments are not provided any mechanism to select specific extras.
if req.marker is not None and not req.marker.evaluate({"extra": ""}):
continue
dist = env.get_distribution(req.name)
if not dist:
missing.add(req_str)
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_build_env.py
Expand Up @@ -178,6 +178,7 @@ def test_build_env_requirements_check(script: PipTestEnvironment) -> None:
[
"bar==2.0; python_version < '3.0'",
"bar==3.0; python_version >= '3.0'",
"foo==4.0; extra == 'dev'",
],
)
assert r == (set(), set()), repr(r)
Expand Down