summaryrefslogtreecommitdiff
path: root/lib/spack/spack/spec.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r--lib/spack/spack/spec.py35
1 files changed, 12 insertions, 23 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index b0eba7363d..61f127a66c 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1197,7 +1197,9 @@ class Spec(object):
@property
def package(self):
- return spack.repo.get(self)
+ if not self._package:
+ self._package = spack.repo.get(self)
+ return self._package
@property
def package_class(self):
@@ -1773,17 +1775,8 @@ class Spec(object):
Some rigorous validation and checks are also performed on the spec.
Concretizing ensures that it is self-consistent and that it's
- consistent with requirements of its pacakges. See flatten() and
+ consistent with requirements of its packages. See flatten() and
normalize() for more details on this.
-
- It also ensures that:
-
- .. code-block:: python
-
- for x in self.traverse():
- assert x.package.spec == x
-
- which may not be true *during* the concretization step.
"""
if not self.name:
raise SpecError("Attempting to concretize anonymous spec")
@@ -1872,7 +1865,7 @@ class Spec(object):
# there are declared conflicts
matches = []
for x in self.traverse():
- for conflict_spec, when_list in x.package.conflicts.items():
+ for conflict_spec, when_list in x.package_class.conflicts.items():
if x.satisfies(conflict_spec, strict=True):
for when_spec, msg in when_list:
if x.satisfies(when_spec, strict=True):
@@ -1880,11 +1873,6 @@ class Spec(object):
if matches:
raise ConflictsInSpecError(self, matches)
- # At this point the spec-package mutual references should
- # be self-consistent
- for x in self.traverse():
- x.package.spec = x
-
def _mark_concrete(self, value=True):
"""Mark this spec and its dependencies as concrete.
@@ -1968,8 +1956,7 @@ class Spec(object):
If no conditions are True (and we don't depend on it), return
``(None, None)``.
"""
- pkg = spack.repo.get(self.fullname)
- conditions = pkg.dependencies[name]
+ conditions = self.package_class.dependencies[name]
substitute_abstract_variants(self)
# evaluate when specs to figure out constraints on the dependency.
@@ -2136,10 +2123,9 @@ class Spec(object):
any_change = False
changed = True
- pkg = spack.repo.get(self.fullname)
while changed:
changed = False
- for dep_name in pkg.dependencies:
+ for dep_name in self.package_class.dependencies:
# Do we depend on dep_name? If so pkg_dep is not None.
dep = self._evaluate_dependency_conditions(dep_name)
# If dep is a needed dependency, merge it.
@@ -2556,7 +2542,7 @@ class Spec(object):
# FIXME: concretization to store the order of patches somewhere.
# FIXME: Needs to be refactored in a cleaner way.
for sha256 in self.variants['patches']._patches_in_order_of_appearance:
- patch = self.package.lookup_patch(sha256)
+ patch = self.package_class.lookup_patch(sha256)
if patch:
patches.append(patch)
continue
@@ -2564,7 +2550,7 @@ class Spec(object):
# if not found in this package, check immediate dependents
# for dependency patches
for dep_spec in self._dependents.values():
- patch = dep_spec.parent.package.lookup_patch(sha256)
+ patch = dep_spec.parent.package_class.lookup_patch(sha256)
if patch:
patches.append(patch)
@@ -2610,6 +2596,8 @@ class Spec(object):
self.external_module != other.external_module and
self.compiler_flags != other.compiler_flags)
+ self._package = None
+
# Local node attributes get copied first.
self.name = other.name
self.versions = other.versions.copy()
@@ -3374,6 +3362,7 @@ class SpecParser(spack.parse.Parser):
spec._hash = None
spec._cmp_key_cache = None
+ spec._package = None
spec._normal = False
spec._concrete = False