diff options
Diffstat (limited to 'lib/spack/spack/repository.py')
-rw-r--r-- | lib/spack/spack/repository.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py index dedab9f51c..474dd4127e 100644 --- a/lib/spack/spack/repository.py +++ b/lib/spack/spack/repository.py @@ -542,19 +542,21 @@ class RepoPath(object): """Given a spec, get the repository for its package.""" # We don't @_autospec this function b/c it's called very frequently # and we want to avoid parsing str's into Specs unnecessarily. + namespace = None 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] + namespace = spec.namespace name = spec.name - else: # handle strings directly for speed instead of @_autospec'ing - name = spec + namespace, _, name = spec.rpartition('.') + + # If the spec already has a namespace, then return the + # corresponding repo if we know about it. + if namespace: + fullspace = '%s.%s' % (self.super_namespace, namespace) + if fullspace not in self.by_namespace: + raise UnknownNamespaceError(spec.namespace) + return self.by_namespace[fullspace] # If there's no namespace, search in the RepoPath. for repo in self.repos: @@ -818,7 +820,7 @@ class Repo(object): @_autospec def get(self, spec, new=False): - if spec.virtual: + if not self.exists(spec.name): raise UnknownPackageError(spec.name) if spec.namespace and spec.namespace != self.namespace: |