Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After least versions, the package with least dependencies is chosen #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions mixology/version_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,17 @@ def _next_term_to_try(self): # type: () -> Optional[Term]

# Prefer packages with as few remaining versions as possible,
# so that if a conflict is necessary it's forced quickly.
# at a tie, the package with least dependencies is chosen
def _get_min(term):
return len(
self._source.versions_for(term.package, term.constraint.constraint)
versions = self._source.versions_for(
term.package, term.constraint.constraint
)
deps = (
self._source.dependencies_for(term.package, versions[0])
if versions
else []
)
return len(versions), len(deps)

if len(unsatisfied) == 1:
term = unsatisfied[0]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_unsolvable.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def test_no_version_that_matches_combined_constraints(source):
source.add("shared", "3.5.0")

error = """\
Because foo (1.0.0) depends on shared (>=2.0.0 <3.0.0)
and no versions of shared match >=2.9.0,<3.0.0, foo (1.0.0) requires shared (>=2.0.0,<2.9.0).
And because bar (1.0.0) depends on shared (>=2.9.0 <4.0.0), bar (1.0.0) is incompatible with foo (1.0.0).
Because no versions of shared match >=2.9.0,<3.0.0
and bar (1.0.0) depends on shared (>=2.9.0 <4.0.0), bar (1.0.0) requires shared (>=3.0.0,<4.0.0).
And because foo (1.0.0) depends on shared (>=2.0.0 <3.0.0), bar (1.0.0) is incompatible with foo (1.0.0).
So, because root depends on both foo (1.0.0) and bar (1.0.0), version solving failed."""

check_solver_result(source, error=error)
Expand Down