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.
This commit is contained in:
Todd Gamblin 2023-05-13 11:34:15 -07:00 committed by GitHub
parent e9bfe5cd35
commit c5a24675a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 21 deletions

View file

@ -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,

View file

@ -80,12 +80,15 @@ def setup_parser(subparser):
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,

View file

@ -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,

View file

@ -144,9 +144,20 @@
#: ``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.

View file

@ -24,12 +24,12 @@
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(