diff options
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r-- | lib/spack/spack/spec.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 9f25dd0487..b0eba7363d 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -884,6 +884,9 @@ class SpecBuildInterface(ObjectWrapper): @key_ordering class Spec(object): + #: Cache for spec's prefix, computed lazily in the corresponding property + _prefix = None + @staticmethod def from_literal(spec_dict, normal=True): """Builds a Spec from a dictionary containing the spec literal. @@ -1374,12 +1377,13 @@ class Spec(object): @property def prefix(self): - if hasattr(self, 'test_prefix'): - return Prefix(self.test_prefix) - return Prefix(spack.store.layout.path_for_spec(self)) + if self._prefix is None: + self.prefix = spack.store.layout.path_for_spec(self) + return self._prefix - def _set_test_prefix(self, val): - self.test_prefix = val + @prefix.setter + def prefix(self, value): + self._prefix = Prefix(value) def dag_hash(self, length=None): """Return a hash of the entire spec DAG, including connectivity.""" |