summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWouter Deconinck <wdconinc@gmail.com>2023-08-02 06:16:14 -0500
committerGitHub <noreply@github.com>2023-08-02 11:16:14 +0000
commita14f4b5a028df4a669fbebab1e6a8f2b57288baf (patch)
tree59ab7d8f2668fc65da9c84265df5c657bee3dcb0 /lib
parent3be565f49e7a694fb7cbeda6c82b3257b51f9786 (diff)
downloadspack-a14f4b5a028df4a669fbebab1e6a8f2b57288baf.tar.gz
spack-a14f4b5a028df4a669fbebab1e6a8f2b57288baf.tar.bz2
spack-a14f4b5a028df4a669fbebab1e6a8f2b57288baf.tar.xz
spack-a14f4b5a028df4a669fbebab1e6a8f2b57288baf.zip
feat: move -N/--namespace(s) to common args, allow in `buildcache list` (#36719)
`spack buildcache list` did not have a way to display the namespace of packages in the buildcache. This PR adds that functionality. For consistency's sake, it moves the `-N/--namespace` arg definition to the `common/arguments.py` and modifies `find`, `solve`, `spec` to use the common definition. Previously, `find` was using `--namespace` (singular) to control whether to display the namespace (it doesn't restrict the search to that namespace). The other commands were using `--namespaces` (plural). For backwards compatibility and for consistency with `--deps`, `--tags`, etc, the plural `--namespaces` was chosen. The argument parser ensures that `find --namespace` will continue to behave as before. Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/__init__.py6
-rw-r--r--lib/spack/spack/cmd/buildcache.py2
-rw-r--r--lib/spack/spack/cmd/common/arguments.py11
-rw-r--r--lib/spack/spack/cmd/find.py7
-rw-r--r--lib/spack/spack/cmd/solve.py9
-rw-r--r--lib/spack/spack/cmd/spec.py9
-rw-r--r--lib/spack/spack/test/cmd/find.py12
7 files changed, 25 insertions, 31 deletions
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
index e9369ead64..d7fca9f561 100644
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -383,7 +383,7 @@ def display_specs(specs, args=None, **kwargs):
deps (bool): Display dependencies with specs
long (bool): Display short hashes with specs
very_long (bool): Display full hashes with specs (supersedes ``long``)
- namespace (bool): Print namespaces along with names
+ namespaces (bool): Print namespaces along with names
show_flags (bool): Show compiler flags with specs
variants (bool): Show variants with specs
indent (int): indent each line this much
@@ -407,7 +407,7 @@ def display_specs(specs, args=None, **kwargs):
paths = get_arg("paths", False)
deps = get_arg("deps", False)
hashes = get_arg("long", False)
- namespace = get_arg("namespace", False)
+ namespaces = get_arg("namespaces", False)
flags = get_arg("show_flags", False)
full_compiler = get_arg("show_full_compiler", False)
variants = get_arg("variants", False)
@@ -428,7 +428,7 @@ def display_specs(specs, args=None, **kwargs):
format_string = get_arg("format", None)
if format_string is None:
- nfmt = "{fullname}" if namespace else "{name}"
+ nfmt = "{fullname}" if namespaces else "{name}"
ffmt = ""
if full_compiler or flags:
ffmt += "{%compiler.name}"
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index 416fb88a80..d30498f0b5 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -105,7 +105,7 @@ def setup_parser(subparser):
install.set_defaults(func=install_fn)
listcache = subparsers.add_parser("list", help=list_fn.__doc__)
- arguments.add_common_arguments(listcache, ["long", "very_long"])
+ arguments.add_common_arguments(listcache, ["long", "very_long", "namespaces"])
listcache.add_argument(
"-v",
"--variants",
diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py
index 9427707002..4adfd467a0 100644
--- a/lib/spack/spack/cmd/common/arguments.py
+++ b/lib/spack/spack/cmd/common/arguments.py
@@ -332,6 +332,17 @@ def tags():
@arg
+def namespaces():
+ return Args(
+ "-N",
+ "--namespaces",
+ action="store_true",
+ default=False,
+ help="show fully qualified package names",
+ )
+
+
+@arg
def jobs():
return Args(
"-j",
diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py
index 15ea5c7709..49f49a2c94 100644
--- a/lib/spack/spack/cmd/find.py
+++ b/lib/spack/spack/cmd/find.py
@@ -67,7 +67,7 @@ def setup_parser(subparser):
help="do not group specs by arch/compiler",
)
- arguments.add_common_arguments(subparser, ["long", "very_long", "tags"])
+ arguments.add_common_arguments(subparser, ["long", "very_long", "tags", "namespaces"])
subparser.add_argument(
"-c",
@@ -140,9 +140,6 @@ def setup_parser(subparser):
subparser.add_argument(
"--only-deprecated", action="store_true", help="show only deprecated packages"
)
- subparser.add_argument(
- "-N", "--namespace", action="store_true", help="show fully qualified package names"
- )
subparser.add_argument("--start-date", help="earliest date of installation [YYYY-MM-DD]")
subparser.add_argument("--end-date", help="latest date of installation [YYYY-MM-DD]")
@@ -230,7 +227,7 @@ def display_env(env, args, decorator, results):
env.user_specs,
root_args,
decorator=lambda s, f: color.colorize("@*{%s}" % f),
- namespace=True,
+ namespaces=True,
show_flags=True,
show_full_compiler=True,
variants=True,
diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py
index 0ccbb4c0e7..9a13dec108 100644
--- a/lib/spack/spack/cmd/solve.py
+++ b/lib/spack/spack/cmd/solve.py
@@ -42,7 +42,7 @@ def setup_parser(subparser):
)
# Below are arguments w.r.t. spec display (like spack spec)
- arguments.add_common_arguments(subparser, ["long", "very_long"])
+ arguments.add_common_arguments(subparser, ["long", "very_long", "namespaces"])
install_status_group = subparser.add_mutually_exclusive_group()
arguments.add_common_arguments(install_status_group, ["install_status", "no_install_status"])
@@ -74,13 +74,6 @@ def setup_parser(subparser):
help="how extensively to traverse the DAG (default: nodes)",
)
subparser.add_argument(
- "-N",
- "--namespaces",
- action="store_true",
- default=False,
- help="show fully qualified package names",
- )
- subparser.add_argument(
"-t", "--types", action="store_true", default=False, help="show dependency types"
)
subparser.add_argument(
diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py
index 3026cffd65..05a1a67da6 100644
--- a/lib/spack/spack/cmd/spec.py
+++ b/lib/spack/spack/cmd/spec.py
@@ -29,7 +29,7 @@ specs are used instead
for further documentation regarding the spec syntax, see:
spack help --spec
"""
- arguments.add_common_arguments(subparser, ["long", "very_long"])
+ arguments.add_common_arguments(subparser, ["long", "very_long", "namespaces"])
install_status_group = subparser.add_mutually_exclusive_group()
arguments.add_common_arguments(install_status_group, ["install_status", "no_install_status"])
@@ -68,13 +68,6 @@ for further documentation regarding the spec syntax, see:
help="how extensively to traverse the DAG (default: nodes)",
)
subparser.add_argument(
- "-N",
- "--namespaces",
- action="store_true",
- default=False,
- help="show fully qualified package names",
- )
- subparser.add_argument(
"-t", "--types", action="store_true", default=False, help="show dependency types"
)
arguments.add_common_arguments(subparser, ["specs"])
diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py
index cf702c0989..830d1d255b 100644
--- a/lib/spack/spack/test/cmd/find.py
+++ b/lib/spack/spack/test/cmd/find.py
@@ -117,13 +117,13 @@ def test_tag2_tag3(parser, specs):
assert len(specs) == 0
+@pytest.mark.parametrize(
+ "args,with_namespace", [([], False), (["--namespace"], True), (["--namespaces"], True)]
+)
@pytest.mark.db
-def test_namespaces_shown_correctly(database):
- out = find()
- assert "builtin.mock.zmpi" not in out
-
- out = find("--namespace")
- assert "builtin.mock.zmpi" in out
+def test_namespaces_shown_correctly(args, with_namespace, database):
+ """Test that --namespace(s) works. Old syntax is --namespace"""
+ assert ("builtin.mock.zmpi" in find(*args)) == with_namespace
@pytest.mark.db