From e7cba04b95e599b86c6fe0133dc1e227e6257d1c Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 10 Feb 2021 01:26:54 -0800 Subject: bugfix: do not generate dep conditions when no dependency We only consider test dependencies some of the time. Some packages are *only* test dependencies. Spack's algorithm was previously generating dependency conditions that could hold, *even* if there was no potential dependency type. - [x] change asp.py so that this can't happen -- we now only generate dependency types for possible dependencies. --- lib/spack/spack/solver/asp.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index c2dd241477..03ab086423 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -683,21 +683,26 @@ class SpackSolverSetup(object): """Translate 'depends_on' directives into ASP logic.""" for _, conditions in sorted(pkg.dependencies.items()): for cond, dep in sorted(conditions.items()): + deptypes = dep.type.copy() + # Skip test dependencies if they're not requested + if not tests: + deptypes.discard("test") + + # ... or if they are requested only for certain packages + if not isinstance(tests, bool) and pkg.name not in tests: + deptypes.discard("test") + + # if there are no dependency types to be considered + # anymore, don't generate the dependency + if not deptypes: + continue + condition_id = self.condition(cond, dep.spec, pkg.name) self.gen.fact(fn.dependency_condition( condition_id, pkg.name, dep.spec.name )) - for t in sorted(dep.type): - # Skip test dependencies if they're not requested at all - if t == 'test' and not tests: - continue - - # ... or if they are requested only for certain packages - if t == 'test' and (not isinstance(tests, bool) - and pkg.name not in tests): - continue - + for t in sorted(deptypes): # there is a declared dependency of type t self.gen.fact(fn.dependency_type(condition_id, t)) -- cgit v1.2.3-60-g2f50