From e29049d9c0cd81aed571874d8d23a6d58f26fb62 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 5 Dec 2023 05:31:40 -0600 Subject: [PATCH] bugfix: sort variants in `spack info --variants-by-name` (#41389) This was missed while backporting the new `spack info` command from #40326. Variants should be sorted by name when invoking `spack info --variants-by-name`. --- lib/spack/spack/cmd/info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py index dd56c25451..af03fd9397 100644 --- a/lib/spack/spack/cmd/info.py +++ b/lib/spack/spack/cmd/info.py @@ -327,7 +327,7 @@ def _variants_by_name_when(pkg): """Adaptor to get variants keyed by { name: { when: { [Variant...] } }.""" # TODO: replace with pkg.variants_by_name(when=True) when unified directive dicts are merged. variants = {} - for name, (variant, whens) in pkg.variants.items(): + for name, (variant, whens) in sorted(pkg.variants.items()): for when in whens: variants.setdefault(name, {}).setdefault(when, []).append(variant) return variants