summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-14 04:59:29 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-14 04:59:29 -0700
commit05c761dee9c86faf9ce6d5b98ae57c8737694898 (patch)
tree36e1993165f55f4617faef49222bdebebec4e242
parent003fd4d834d3e06ea89c7f3c2fa13241b0730f06 (diff)
downloadspack-05c761dee9c86faf9ce6d5b98ae57c8737694898.tar.gz
spack-05c761dee9c86faf9ce6d5b98ae57c8737694898.tar.bz2
spack-05c761dee9c86faf9ce6d5b98ae57c8737694898.tar.xz
spack-05c761dee9c86faf9ce6d5b98ae57c8737694898.zip
Add `package_class` method to spec.
- Shouldn't call .package from within things like normalize() and concretize() beacuse spec may be inconsistent. - Add `.package_class` property so that we can get at package metadata without constructing a Package with a Spec. - should be faster than `.package` was, anyway. Use where possible.
-rw-r--r--lib/spack/spack/concretize.py2
-rw-r--r--lib/spack/spack/repository.py9
-rw-r--r--lib/spack/spack/spec.py12
3 files changed, 18 insertions, 5 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 8d29a03f93..445ecd8896 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -238,7 +238,7 @@ class DefaultConcretizer(object):
the default variants from the package specification.
"""
changed = False
- for name, variant in spec.package.variants.items():
+ for name, variant in spec.package_class.variants.items():
if name not in spec.variants:
spec.variants[name] = spack.spec.VariantSpec(name, variant.default)
changed = True
diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py
index 3c3ba08bcc..d2fdc937f7 100644
--- a/lib/spack/spack/repository.py
+++ b/lib/spack/spack/repository.py
@@ -316,6 +316,11 @@ class RepoPath(object):
return self.repo_for_pkg(spec).get(spec)
+ def get_pkg_class(self, pkg_name):
+ """Find a class for the spec's package and return the class object."""
+ return self.repo_for_pkg(pkg_name).get_pkg_class(pkg_name)
+
+
@_autospec
def dump_provenance(self, spec, path):
"""Dump provenance information for a spec to a particular path.
@@ -550,7 +555,7 @@ class Repo(object):
key = hash(spec)
if new or key not in self._instances:
- package_class = self._get_pkg_class(spec.name)
+ package_class = self.get_pkg_class(spec.name)
try:
copy = spec.copy() # defensive copy. Package owns its spec.
self._instances[key] = package_class(copy)
@@ -715,7 +720,7 @@ class Repo(object):
return self._modules[pkg_name]
- def _get_pkg_class(self, pkg_name):
+ def get_pkg_class(self, pkg_name):
"""Get the class for the package out of its module.
First loads (or fetches from cache) a module for the
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index c045e80365..573e288d17 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -353,7 +353,7 @@ class VariantMap(HashableMap):
@property
def concrete(self):
return self.spec._concrete or all(
- v in self for v in self.spec.package.variants)
+ v in self for v in self.spec.package_class.variants)
def copy(self):
@@ -499,6 +499,14 @@ class Spec(object):
@property
+ def package_class(self):
+ """Internal package call gets only the class object for a package.
+ Use this to just get package metadata.
+ """
+ return spack.repo.get_pkg_class(self.name)
+
+
+ @property
def virtual(self):
"""Right now, a spec is virtual if no package exists with its name.
@@ -1161,7 +1169,7 @@ class Spec(object):
# Ensure that variants all exist.
for vname, variant in spec.variants.items():
- if vname not in spec.package.variants:
+ if vname not in spec.package_class.variants:
raise UnknownVariantError(spec.name, vname)