Skip to content

Commit

Permalink
resolver.py: Fix is_satisfied_by()
Browse files Browse the repository at this point in the history
is_satisfied_by() returns false if a requirement is defined without a
specifier.  For example using 'aotriton' (no other arguments) results in a
failure regardless of any constraint specified.  In this case it is safe
to return True and return a tested value for the constraint.

Fix is_satisfied_by() to handle requirements without specifiers.

Signed-off-by: Prarit Bhargava <[email protected]>
  • Loading branch information
prarit committed Jan 29, 2025
1 parent 92c7bc0 commit 656a8c0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/fromager/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,14 @@ def is_satisfied_by(self, requirement: Requirement, candidate: Candidate) -> boo
allow_prerelease = self.constraints.allow_prerelease(requirement.name) or bool(
requirement.specifier.prereleases
)
return requirement.specifier.contains(
candidate.version, prereleases=allow_prerelease
) and self.constraints.is_satisfied_by(requirement.name, candidate.version)
reqbool = True
if len(requirement.specifier) == 1:
reqbool = requirement.specifier.contains(
candidate.version, prereleases=allow_prerelease
)
return reqbool and self.constraints.is_satisfied_by(
requirement.name, candidate.version
)

def get_dependencies(self, candidate: Candidate) -> list[Requirement]:
# return candidate.dependencies
Expand Down

0 comments on commit 656a8c0

Please sign in to comment.