Skip to content

Commit 0a982f6

Browse files
authored
Merge pull request #11112 from pradyunsg/filter-out-build-env-extras
Filter out build requirements that require an extra to be used
2 parents d0c89a1 + bf090d3 commit 0a982f6

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

news/11112.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Properly filter out optional dependencies (i.e. extras) when checking build environment distributions.

src/pip/_internal/build_env.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ def check_requirements(
175175
)
176176
for req_str in reqs:
177177
req = Requirement(req_str)
178-
if req.marker is not None and not req.marker.evaluate():
179-
continue # FIXME: Consider extras?
178+
# We're explicitly evaluating with an empty extra value, since build
179+
# environments are not provided any mechanism to select specific extras.
180+
if req.marker is not None and not req.marker.evaluate({"extra": ""}):
181+
continue
180182
dist = env.get_distribution(req.name)
181183
if not dist:
182184
missing.add(req_str)

tests/functional/test_build_env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def test_build_env_requirements_check(script: PipTestEnvironment) -> None:
178178
[
179179
"bar==2.0; python_version < '3.0'",
180180
"bar==3.0; python_version >= '3.0'",
181+
"foo==4.0; extra == 'dev'",
181182
],
182183
)
183184
assert r == (set(), set()), repr(r)

0 commit comments

Comments
 (0)