concretizer: ensure that no deprecated spec is being used

This is done after the builder has actually built
the specs, to respect the semantics use with the
old concretizer.

A better approach is to substitute the spec
directly in concretization.
This commit is contained in:
Massimiliano Culpo 2020-10-21 22:59:40 +02:00 committed by Todd Gamblin
parent 58683b9e56
commit a1fe88c95b
2 changed files with 30 additions and 16 deletions

View file

@ -1668,6 +1668,9 @@ def build_specs(self, function_tuples):
for s in self._specs.values(): for s in self._specs.values():
spack.spec.Spec.ensure_external_path_if_external(s) 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 return self._specs

View file

@ -2364,27 +2364,13 @@ def _old_concretize(self, tests=False):
for s in self.traverse(): for s in self.traverse():
# TODO: Refactor this into a common method to build external specs # TODO: Refactor this into a common method to build external specs
# TODO: or turn external_path into a lazy property # 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. # Mark everything in the spec as concrete, as well.
self._mark_concrete() self._mark_concrete()
# If any spec in the DAG is deprecated, throw an error # If any spec in the DAG is deprecated, throw an error
deprecated = [] Spec.ensure_no_deprecated(self)
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)
# Now that the spec is concrete we should check if # Now that the spec is concrete we should check if
# there are declared conflicts # there are declared conflicts
@ -2426,6 +2412,31 @@ def ensure_external_path_if_external(external_spec):
md.path_from_modules(external_spec.external_modules) 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): def _new_concretize(self, tests=False):
import spack.solver.asp import spack.solver.asp