diff options
-rw-r--r-- | lib/spack/spack/solver/asp.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 43 |
2 files changed, 30 insertions, 16 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index ed0109856f..1d4602ce62 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1668,6 +1668,9 @@ class SpecBuilder(object): for s in self._specs.values(): spack.spec.Spec.ensure_external_path_if_external(s) + for s in self._specs.values(): + spack.spec.Spec.ensure_no_deprecated(s) + return self._specs diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index e7cc1d7eaf..1e42e90214 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2364,27 +2364,13 @@ class Spec(object): for s in self.traverse(): # TODO: Refactor this into a common method to build external specs # TODO: or turn external_path into a lazy property - self.ensure_external_path_if_external(s) + Spec.ensure_external_path_if_external(s) # Mark everything in the spec as concrete, as well. self._mark_concrete() # If any spec in the DAG is deprecated, throw an error - deprecated = [] - with spack.store.db.read_transaction(): - for x in self.traverse(): - _, rec = spack.store.db.query_by_spec_hash(x.dag_hash()) - if rec and rec.deprecated_for: - deprecated.append(rec) - - if deprecated: - msg = "\n The following specs have been deprecated" - msg += " in favor of specs with the hashes shown:\n" - for rec in deprecated: - msg += ' %s --> %s\n' % (rec.spec, rec.deprecated_for) - msg += '\n' - msg += " For each package listed, choose another spec\n" - raise SpecDeprecatedError(msg) + Spec.ensure_no_deprecated(self) # Now that the spec is concrete we should check if # there are declared conflicts @@ -2426,6 +2412,31 @@ class Spec(object): md.path_from_modules(external_spec.external_modules) ) + @staticmethod + def ensure_no_deprecated(root): + """Raise is a deprecated spec is in the dag. + + Args: + root (Spec): root spec to be analyzed + + Raises: + SpecDeprecatedError: is any deprecated spec is found + """ + deprecated = [] + with spack.store.db.read_transaction(): + for x in root.traverse(): + _, rec = spack.store.db.query_by_spec_hash(x.dag_hash()) + if rec and rec.deprecated_for: + deprecated.append(rec) + if deprecated: + msg = "\n The following specs have been deprecated" + msg += " in favor of specs with the hashes shown:\n" + for rec in deprecated: + msg += ' %s --> %s\n' % (rec.spec, rec.deprecated_for) + msg += '\n' + msg += " For each package listed, choose another spec\n" + raise SpecDeprecatedError(msg) + def _new_concretize(self, tests=False): import spack.solver.asp |