Compare commits

...

3 Commits

Author SHA1 Message Date
Pradyun Gedam 0a982f6444
Merge pull request #11112 from pradyunsg/filter-out-build-env-extras
Filter out build requirements that require an extra to be used
2022-05-12 21:30:00 +01:00
Pradyun Gedam bf090d37d1
📰 2022-05-12 21:22:21 +01:00
Pradyun Gedam 611e9253ff
Filter out build requirements that require an extra to be used
There is no mechanism provided for build requirements to have extras.

It should be acceptable to enforce that any "optional" packages
that are supposed to be conditionally installed based on the presence of
an extra should not be installed in a build environment.
2022-05-12 01:04:11 +01:00
3 changed files with 6 additions and 2 deletions

1
news/11112.bugfix.rst Normal file
View File

@ -0,0 +1 @@
Properly filter out optional dependencies (i.e. extras) when checking build environment distributions.

View File

@ -175,8 +175,10 @@ 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?
# 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)

View File

@ -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)