From 2d2a4d19083fe0eda0a46f6f201a9f9c5609b743 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 26 Mar 2025 10:34:05 -0700 Subject: [PATCH] bugfix: display old-style compilers without `@=` in `spack find` output (#49693) * bugfix: display old-style compilers without `@=` in `spack find` output Fix `display_str` attribute of `DeprecatedCompiler` so that `spack find` displays compilers without `@=` for the version (as expected). - [x] Use `spec.format("{@version}")` to do this before: ``` > spack find -- darwin-sequoia-m1 / apple-clang@=16.0.0 ----------------------- abseil-cpp@20240722.0 py-graphviz@0.13.2 apple-libuuid@1353.100.2 py-hatch-fancy-pypi-readme@23.1.0 ``` after: ``` > spack find -- darwin-sequoia-m1 / apple-clang@16.0.0 ----------------------- abseil-cpp@20240722.0 py-graphviz@0.13.2 apple-libuuid@1353.100.2 py-hatch-fancy-pypi-readme@23.1.0 ``` Signed-off-by: Todd Gamblin * [@spackbot] updating style on behalf of tgamblin --------- Signed-off-by: Todd Gamblin --- lib/spack/spack/spec.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index cf116e1fc16..8232674a840 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -663,11 +663,9 @@ def versions(self): def display_str(self): """Equivalent to {compiler.name}{@compiler.version} for Specs, without extra @= for readability.""" - if self.spec.concrete: - return f"{self.name}@{self.version}" - elif self.versions != vn.any_version: - return f"{self.name}@{self.versions}" - return self.name + if self.versions != vn.any_version: + return self.spec.format("{name}{@version}") + return self.spec.format("{name}") def __lt__(self, other): if not isinstance(other, CompilerSpec):