From afc99ca51699234ee3353013dba8f92cb1d28e2f Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 13 Oct 2017 17:20:23 -0700 Subject: Remove single-root assertion from Spec.root - Assertion would search for root through all possible paths. - It's also really slow. - This isn't needed anymore. We're pretty good at ensuring single-rooted DAGs, and this assertion has never been thrown. - This shaves another 6 seconds off r-rminer concretization --- lib/spack/spack/concretize.py | 4 +++- lib/spack/spack/spec.py | 13 +++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index af3f3a3b18..bcbe1b74b8 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -113,7 +113,9 @@ class DefaultConcretizer(object): # Find the nearest spec in the dag that has a compiler. We'll # use that spec to calibrate compiler compatibility. - abi_exemplar = find_spec(spec, lambda x: x.compiler, spec.root) + abi_exemplar = find_spec(spec, lambda x: x.compiler) + if abi_exemplar is None: + abi_exemplar = spec.root # Sort candidates from most to least compatibility. # We reverse because True > False. diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index ed204deb9e..70a27fb951 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1178,20 +1178,13 @@ class Spec(object): @property def root(self): """Follow dependent links and find the root of this spec's DAG. - In spack specs, there should be a single root (the package being - installed). This will throw an assertion error if that is not - the case. + + Spack specs have a single root (the package being installed). """ if not self._dependents: return self - # If the spec has multiple dependents, ensure that they all - # lead to the same place. Spack shouldn't deal with any DAGs - # with multiple roots, so something's wrong if we find one. - depiter = iter(self._dependents.values()) - first_root = next(depiter).parent.root - assert(all(first_root is d.parent.root for d in depiter)) - return first_root + return next(iter(self._dependents.values())).parent.root @property def package(self): -- cgit v1.2.3-60-g2f50