diff options
-rw-r--r-- | lib/spack/spack/concretize.py | 6 | ||||
-rw-r--r-- | lib/spack/spack/provider_index.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/repository.py | 25 | ||||
-rw-r--r-- | lib/spack/spack/variant.py | 5 |
4 files changed, 23 insertions, 17 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 1aed7d8eb1..10a3705083 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -146,8 +146,8 @@ class DefaultConcretizer(object): return False # List of versions we could consider, in sorted order - pkg = spec.package - usable = [v for v in pkg.versions + pkg_versions = spec.package_class.versions + usable = [v for v in pkg_versions if any(v.satisfies(sv) for sv in spec.versions)] yaml_prefs = PackagePrefs(spec.name, 'version') @@ -165,7 +165,7 @@ class DefaultConcretizer(object): -yaml_prefs(v), # The preferred=True flag (packages or packages.yaml or both?) - pkg.versions.get(Version(v)).get('preferred', False), + pkg_versions.get(Version(v)).get('preferred', False), # ------- Regular case: use latest non-develop version by default. # Avoid @develop version, which would otherwise be the "largest" diff --git a/lib/spack/spack/provider_index.py b/lib/spack/spack/provider_index.py index 054f1ca807..15cb3e785e 100644 --- a/lib/spack/spack/provider_index.py +++ b/lib/spack/spack/provider_index.py @@ -97,8 +97,8 @@ class ProviderIndex(object): assert(not spec.virtual) - pkg = spec.package - for provided_spec, provider_specs in iteritems(pkg.provided): + pkg_provided = spec.package_class.provided + for provided_spec, provider_specs in iteritems(pkg_provided): for provider_spec in provider_specs: # TODO: fix this comment. # We want satisfaction other than flags diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py index 0a43cf8af1..ba33e24069 100644 --- a/lib/spack/spack/repository.py +++ b/lib/spack/spack/repository.py @@ -537,20 +537,27 @@ class RepoPath(object): sys.modules[fullname] = module return module - @_autospec def repo_for_pkg(self, spec): """Given a spec, get the repository for its package.""" - # If the spec already has a namespace, then return the - # corresponding repo if we know about it. - if spec.namespace: - fullspace = '%s.%s' % (self.super_namespace, spec.namespace) - if fullspace not in self.by_namespace: - raise UnknownNamespaceError(spec.namespace) - return self.by_namespace[fullspace] + # We don't @_autospec this function b/c it's called very frequently + # and we want to avoid parsing str's into Specs unnecessarily. + if isinstance(spec, spack.spec.Spec): + # If the spec already has a namespace, then return the + # corresponding repo if we know about it. + if spec.namespace: + fullspace = '%s.%s' % (self.super_namespace, spec.namespace) + if fullspace not in self.by_namespace: + raise UnknownNamespaceError(spec.namespace) + return self.by_namespace[fullspace] + name = spec.name + + else: + # handle strings directly for speed instead of @_autospec'ing + name = spec # If there's no namespace, search in the RepoPath. for repo in self.repos: - if spec.name in repo: + if name in repo: return repo # If the package isn't in any repo, return the one with diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py index 3f9ede1047..4553bf53e4 100644 --- a/lib/spack/spack/variant.py +++ b/lib/spack/spack/variant.py @@ -592,10 +592,9 @@ def substitute_abstract_variants(spec): spec: spec on which to operate the substitution """ for name, v in spec.variants.items(): - pkg_cls = type(spec.package) - pkg_variant = spec.package.variants[name] + pkg_variant = spec.package_class.variants[name] new_variant = pkg_variant.make_variant(v._original_value) - pkg_variant.validate_or_raise(new_variant, pkg_cls) + pkg_variant.validate_or_raise(new_variant, spec.package_class) spec.variants.substitute(new_variant) |