summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2020-10-21 22:59:40 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commita1fe88c95b3ba95cb5490db96c950b139c11b659 (patch)
tree8b01ed77f62fe6b2104f671a1e38ccb47edd0090 /lib
parent58683b9e5625f7f48883ae01263a77ae22f2e124 (diff)
downloadspack-a1fe88c95b3ba95cb5490db96c950b139c11b659.tar.gz
spack-a1fe88c95b3ba95cb5490db96c950b139c11b659.tar.bz2
spack-a1fe88c95b3ba95cb5490db96c950b139c11b659.tar.xz
spack-a1fe88c95b3ba95cb5490db96c950b139c11b659.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py3
-rw-r--r--lib/spack/spack/spec.py43
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