summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2023-05-13 11:34:15 -0700
committerGitHub <noreply@github.com>2023-05-13 11:34:15 -0700
commitc5a24675a16e3e85f4e75d2700d0106882879464 (patch)
treec35b124ff24d4467e95d1a7375fd78983467261e /lib
parente9bfe5cd3529dd24bc193efe162f9771e22f6625 (diff)
downloadspack-c5a24675a16e3e85f4e75d2700d0106882879464.tar.gz
spack-c5a24675a16e3e85f4e75d2700d0106882879464.tar.bz2
spack-c5a24675a16e3e85f4e75d2700d0106882879464.tar.xz
spack-c5a24675a16e3e85f4e75d2700d0106882879464.zip
`spack spec`: remove noisy `@=` from output (#37663)
@= is accurate, but noisy. Other UI commands tend not to print the redundant `@=` for known concrete versions; make `spack spec` consistent with them.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/solve.py9
-rw-r--r--lib/spack/spack/cmd/spec.py9
-rw-r--r--lib/spack/spack/environment/environment.py1
-rw-r--r--lib/spack/spack/spec.py17
-rw-r--r--lib/spack/spack/test/cmd/spec.py24
5 files changed, 39 insertions, 21 deletions
diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py
index fbb4d358ef..b97b405ccb 100644
--- a/lib/spack/spack/cmd/solve.py
+++ b/lib/spack/spack/cmd/solve.py
@@ -140,12 +140,15 @@ def _process_result(result, show, required_format, kwargs):
def solve(parser, args):
# these are the same options as `spack spec`
- name_fmt = "{namespace}.{name}" if args.namespaces else "{name}"
- fmt = "{@versions}{%compiler}{compiler_flags}{variants}{arch=architecture}"
install_status_fn = spack.spec.Spec.install_status
+
+ fmt = spack.spec.display_format
+ if args.namespaces:
+ fmt = "{namespace}." + fmt
+
kwargs = {
"cover": args.cover,
- "format": name_fmt + fmt,
+ "format": fmt,
"hashlen": None if args.very_long else 7,
"show_types": args.types,
"status_fn": install_status_fn if args.install_status else None,
diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py
index fc3ff05437..6fabc73310 100644
--- a/lib/spack/spack/cmd/spec.py
+++ b/lib/spack/spack/cmd/spec.py
@@ -80,12 +80,15 @@ for further documentation regarding the spec syntax, see:
def spec(parser, args):
- name_fmt = "{namespace}.{name}" if args.namespaces else "{name}"
- fmt = "{@versions}{%compiler}{compiler_flags}{variants}{arch=architecture}"
install_status_fn = spack.spec.Spec.install_status
+
+ fmt = spack.spec.display_format
+ if args.namespaces:
+ fmt = "{namespace}." + fmt
+
tree_kwargs = {
"cover": args.cover,
- "format": name_fmt + fmt,
+ "format": fmt,
"hashlen": None if args.very_long else 7,
"show_types": args.types,
"status_fn": install_status_fn if args.install_status else None,
diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py
index 941fa31e46..e49d7854c4 100644
--- a/lib/spack/spack/environment/environment.py
+++ b/lib/spack/spack/environment/environment.py
@@ -2324,6 +2324,7 @@ def display_specs(concretized_specs):
def _tree_to_display(spec):
return spec.tree(
recurse_dependencies=True,
+ format=spack.spec.display_format,
status_fn=spack.spec.Spec.install_status,
hashlen=7,
hashes=True,
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index a16efd336c..7d3014a71d 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -144,9 +144,20 @@ color_formats = {
#: ``color_formats.keys()``.
_separators = "[\\%s]" % "\\".join(color_formats.keys())
-default_format = "{name}{@versions}"
-default_format += "{%compiler.name}{@compiler.versions}{compiler_flags}"
-default_format += "{variants}{arch=architecture}{/abstract_hash}"
+#: Default format for Spec.format(). This format can be round-tripped, so that:
+#: Spec(Spec("string").format()) == Spec("string)"
+default_format = (
+ "{name}{@versions}"
+ "{%compiler.name}{@compiler.versions}{compiler_flags}"
+ "{variants}{arch=architecture}{/abstract_hash}"
+)
+
+#: Display format, which eliminates extra `@=` in the output, for readability.
+display_format = (
+ "{name}{@version}"
+ "{%compiler.name}{@compiler.version}{compiler_flags}"
+ "{variants}{arch=architecture}{/abstract_hash}"
+)
#: Regular expression to pull spec contents out of clearsigned signature
#: file.
diff --git a/lib/spack/spack/test/cmd/spec.py b/lib/spack/spack/test/cmd/spec.py
index 09e7b8725e..9d1ca0cf84 100644
--- a/lib/spack/spack/test/cmd/spec.py
+++ b/lib/spack/spack/test/cmd/spec.py
@@ -24,12 +24,12 @@ spec = SpackCommand("spec")
def test_spec():
output = spec("mpileaks")
- assert "mpileaks@=2.3" in output
- assert "callpath@=1.0" in output
- assert "dyninst@=8.2" in output
- assert "libdwarf@=20130729" in output
- assert "libelf@=0.8.1" in output
- assert "mpich@=3.0.4" in output
+ assert "mpileaks@2.3" in output
+ assert "callpath@1.0" in output
+ assert "dyninst@8.2" in output
+ assert "libdwarf@20130729" in output
+ assert "libelf@0.8.1" in output
+ assert "mpich@3.0.4" in output
def test_spec_concretizer_args(mutable_config, mutable_database):
@@ -197,12 +197,12 @@ def test_env_aware_spec(mutable_mock_env_path):
with env:
output = spec()
- assert "mpileaks@=2.3" in output
- assert "callpath@=1.0" in output
- assert "dyninst@=8.2" in output
- assert "libdwarf@=20130729" in output
- assert "libelf@=0.8.1" in output
- assert "mpich@=3.0.4" in output
+ assert "mpileaks@2.3" in output
+ assert "callpath@1.0" in output
+ assert "dyninst@8.2" in output
+ assert "libdwarf@20130729" in output
+ assert "libelf@0.8.1" in output
+ assert "mpich@3.0.4" in output
@pytest.mark.parametrize(