Skip to content

Commit eb8a3df

Browse files
authored
fix: apply resolution.excludes when evaluating candidates from the lock file (#3727)
Close #3726 Signed-off-by: Frost Ming <me@frostming.com>
1 parent 1d31c8d commit eb8a3df

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

news/3726.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that `resolution.excludes` is not applied when evaluating candidates from the lock file.

src/pdm/models/repositories/lock.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from dep_logic.markers import AnyMarker, BaseMarker
1111

12+
from pdm.cli.utils import normalize_name
1213
from pdm.exceptions import CandidateNotFound, PdmException
1314
from pdm.models.candidates import Candidate
1415
from pdm.models.markers import EnvSpec, exclude_multi, get_marker
@@ -254,8 +255,11 @@ def get_hashes(self, candidate: Candidate) -> list[FileHash]:
254255

255256
def evaluate_candidates(self, groups: Collection[str], evaluate_markers: bool = True) -> Iterable[Package]:
256257
extras, dependency_groups = self.environment.project.split_extras_groups(list(groups))
258+
excludes = {normalize_name(k) for k in self.environment.project.pyproject.resolution.get("excludes", [])}
257259
for package in self.packages.values():
258260
can = package.candidate
261+
if package.candidate.req.key in excludes:
262+
continue
259263
if evaluate_markers and can.req.marker and not can.req.marker.matches(self.env_spec):
260264
continue
261265
if not package.marker.evaluate({"extras": set(extras), "dependency_groups": set(dependency_groups)}):

0 commit comments

Comments
 (0)