From 5e75a5c81ca4be5622e755723a4573640b8109e9 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Thu, 5 Nov 2015 14:55:24 -0800 Subject: [PATCH] Fixed bug that spack.db.exists() returned True for anonymous specs --- lib/spack/spack/cmd/find.py | 3 +-- lib/spack/spack/packages.py | 2 +- lib/spack/spack/spec.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py index 0728f3f1b2..6697e52de2 100644 --- a/lib/spack/spack/cmd/find.py +++ b/lib/spack/spack/cmd/find.py @@ -79,7 +79,6 @@ def gray_hash(spec, length): def display_specs(specs, **kwargs): mode = kwargs.get('mode', 'short') hashes = kwargs.get('long', False) - print hashes hlen = 7 if kwargs.get('very_long', False): @@ -154,7 +153,7 @@ def find(parser, args): # Filter out specs that don't exist. query_specs = spack.cmd.parse_specs(args.query_specs) query_specs, nonexisting = partition_list( - query_specs, lambda s: spack.db.exists(s.name)) + query_specs, lambda s: spack.db.exists(s.name) or s.name == "") if nonexisting: msg = "No such package%s: " % ('s' if len(nonexisting) > 1 else '') diff --git a/lib/spack/spack/packages.py b/lib/spack/spack/packages.py index 80b91f4ef1..2e90e22c29 100644 --- a/lib/spack/spack/packages.py +++ b/lib/spack/spack/packages.py @@ -154,7 +154,7 @@ def all_packages(self): def exists(self, pkg_name): """Whether a package with the supplied name exists .""" if pkg_name == "": - return True + return False return os.path.exists(self.filename_for_package_name(pkg_name)) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 6335567e66..5aac669871 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1175,6 +1175,9 @@ def normalize(self, force=False): TODO: normalize should probably implement some form of cycle detection, to ensure that the spec is actually a DAG. """ + if self.name == "": + raise SpecError("Attempting to normalize anonymous spec") + if self._normal and not force: return False @@ -1217,8 +1220,8 @@ def validate_names(self): UnsupportedCompilerError. """ for spec in self.traverse(): - # Don't get a package for a virtual name. - if not spec.virtual: + # Don't get a package for a virtual name or an anonymous name + if (not spec.virtual) and spack.db.exists(spec.name): spack.db.get(spec.name) # validate compiler in addition to the package name. @@ -1897,6 +1900,9 @@ def empty_spec(self): spec.dependents = DependencyMap() spec.dependencies = DependencyMap() + spec._normal = False + spec._concrete = False + #Should we be able to add cflags eventually? while self.next: if self.accept(ON):