From 425bba2f1ace61fc7a4b3a7100bd3997debfef44 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 2 Aug 2024 13:38:14 -0500 Subject: Allow spec queries by `namespace` (#45416) * Allow spec queries by `namespace` Spack specs have "namespaces" that indicate what package repository they come from, but there has not been a way to use the spec syntax to match one. You can say things like this: ```console spack find builtin.zlib spack find myrepo.zlib ``` But, because namespaces are written as a dot-separated prefix on the name, you can't say "find me all specs in namespace myrepo". The syntax doesn't allow it. This PR allows you to specify anonymous specs with namespaces on the CLI. Specifically you can do queries like this: ```console spack find namespace=builtin spack find namespace=myrepo ``` You can use this anywhere else you use spec syntax, e.g. in a config file to separate installations based on what repo they came from: ```yaml spack: config: install_tree: root: $spack/opt/spack projections: namespace=myrepo: "myrepo_special_path/{name}-{hash}" namespace=builtin: "builtin/{name}-{hash}" ``` This PR adds a special `namespace_if_anonymous` attribute to specs, which returns the `namespace` if the spec has no name, otherwise it returns `None`. This allows us to print the namespace for anonymous specs but to continue hiding it for most views, as we've done so far. This is implemented as a special case, but it's one that already exists, along with `platform`, `os`, `target`, etc. This also reserves existing special case names for variants so that users cannot define them in their package files. This change is potentially breaking, but I do not think it will be common. There are no builtin packages with a variant called `namespace`, and defining `os`, `target`, or `platform` as a variant would've likely caused other problems if they were already being used. Signed-off-by: Todd Gamblin --- var/spack/repos/builtin/packages/babelstream/package.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/babelstream/package.py b/var/spack/repos/builtin/packages/babelstream/package.py index f7e6d6fbd5..8ac554fd9b 100644 --- a/var/spack/repos/builtin/packages/babelstream/package.py +++ b/var/spack/repos/builtin/packages/babelstream/package.py @@ -56,7 +56,7 @@ class Babelstream(CMakePackage, CudaPackage, ROCmPackage): # ACC conflict variant("cpu_arch", values=str, default="none", description="Enable CPU Target for ACC") - variant("target", values=str, default="none", description="Enable CPU Target for ACC") + variant("acc_target", values=str, default="none", description="Enable CPU Target for ACC") # STD conflicts conflicts("+stddata", when="%gcc@:10.1.0", msg="STD-data requires newer version of GCC") @@ -77,7 +77,7 @@ class Babelstream(CMakePackage, CudaPackage, ROCmPackage): conflicts( "offload=none", when="+raja", - msg="RAJA requires architecture to be specfied by target=[CPU,NVIDIA]", + msg="RAJA requires architecture to be specfied by acc_target=[CPU,NVIDIA]", ) # download raja from https://github.com/LLNL/RAJA -- cgit v1.2.3-70-g09d2