From d8ccca178b35752efa67369442cca58972264fdd Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Fri, 20 Dec 2019 02:25:57 +0100 Subject: [PATCH 1/4] After least versions, the package with least dependencies is chosen --- mixology/version_solver.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mixology/version_solver.py b/mixology/version_solver.py index bb56383..e02a204 100644 --- a/mixology/version_solver.py +++ b/mixology/version_solver.py @@ -324,10 +324,13 @@ 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]) + return len(versions), len(deps) if len(unsatisfied) == 1: term = unsatisfied[0] From 831150f721b9c98c161d1742099b4ba5f36db4ee Mon Sep 17 00:00:00 2001 From: david <14880945+ddelange@users.noreply.github.com> Date: Sun, 22 Dec 2019 13:56:42 +0100 Subject: [PATCH 2/4] Fix test: if no versions available, keep old behaviour --- mixology/version_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixology/version_solver.py b/mixology/version_solver.py index e02a204..5503100 100644 --- a/mixology/version_solver.py +++ b/mixology/version_solver.py @@ -329,7 +329,7 @@ def _get_min(term): versions = self._source.versions_for( term.package, term.constraint.constraint ) - deps = self._source.dependencies_for(term.package, versions[0]) + deps = self._source.dependencies_for(term.package, versions[0]) if versions else [] return len(versions), len(deps) if len(unsatisfied) == 1: From 6906aa77117a68609cbede539e87576d89c29be6 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Mon, 30 Dec 2019 11:39:58 +0100 Subject: [PATCH 3/4] Run black --- mixology/version_solver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mixology/version_solver.py b/mixology/version_solver.py index 5503100..b1bfad8 100644 --- a/mixology/version_solver.py +++ b/mixology/version_solver.py @@ -329,7 +329,11 @@ def _get_min(term): versions = self._source.versions_for( term.package, term.constraint.constraint ) - deps = self._source.dependencies_for(term.package, versions[0]) if versions else [] + deps = ( + self._source.dependencies_for(term.package, versions[0]) + if versions + else [] + ) return len(versions), len(deps) if len(unsatisfied) == 1: From b1fb5c82ebaff8300c1adc7c05ac7a681dfbb0af Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:45:15 +0100 Subject: [PATCH 4/4] Fix test --- tests/test_unsolvable.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_unsolvable.py b/tests/test_unsolvable.py index 90084aa..b93f8fd 100644 --- a/tests/test_unsolvable.py +++ b/tests/test_unsolvable.py @@ -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)