Skip to content

Commit

Permalink
Fix DependencyCache version solving inconsistency with nested prerele…
Browse files Browse the repository at this point in the history
…ase constraints
  • Loading branch information
chriskuehl committed May 21, 2023
1 parent d08bcb7 commit 4ac3bea
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/poetry/mixology/version_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ def _search_for(self, dependency: Dependency) -> list[DependencyPackage]:
)

packages = self.cache.get(key)
if packages is None:
packages = self.provider.search_for(dependency)
else:

if packages:
packages = [
p for p in packages if dependency.constraint.allows(p.package.version)
]

# provider.search_for() normally does not include pre-release packages
# (unless requested), but will include them if there are no other
# eligible package versions for a version constraint.
#
# Therefore, if the eligible versions have been filtered down to
# nothing, we need to call provider.search_for() again as it may return
# additional results this time.
if not packages:
packages = self.provider.search_for(dependency)

self.cache[key] = packages

return packages
Expand Down

0 comments on commit 4ac3bea

Please sign in to comment.