diff --git a/lib/spack/spack/provider_index.py b/lib/spack/spack/provider_index.py index 20595867a41..db5f5d23098 100644 --- a/lib/spack/spack/provider_index.py +++ b/lib/spack/spack/provider_index.py @@ -240,8 +240,8 @@ def from_json(stream, repository): index.providers = _transform( providers, lambda vpkg, plist: ( - spack.spec.SpecfileV5.from_node_dict(vpkg), - set(spack.spec.SpecfileV5.from_node_dict(p) for p in plist), + spack.spec.SpecfileLatest.from_node_dict(vpkg), + set(spack.spec.SpecfileLatest.from_node_dict(p) for p in plist), ), ) return index diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index c7b4b5651dc..474e256d2e9 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -5103,6 +5103,10 @@ def legacy_compiler(cls, node): raise RuntimeError("The 'compiler' option is unexpected in specfiles at v5 or greater") +#: Alias to the latest version of specfiles +SpecfileLatest = SpecfileV5 + + class LazySpecCache(collections.defaultdict): """Cache for Specs that uses a spec_like as key, and computes lazily the corresponding value ``Spec(spec_like``. diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py index 411beb35722..2aee2a31a59 100644 --- a/lib/spack/spack/test/spec_yaml.py +++ b/lib/spack/spack/test/spec_yaml.py @@ -504,3 +504,10 @@ def test_pickle_roundtrip_for_abstract_specs(spec_str): t = pickle.loads(pickle.dumps(s)) assert s == t assert str(s) == str(t) + + +def test_specfile_alias_is_updated(): + """Tests that the SpecfileLatest alias gets updated on a Specfile version bump""" + specfile_class_name = f"SpecfileV{spack.spec.SPECFILE_FORMAT_VERSION}" + specfile_cls = getattr(spack.spec, specfile_class_name) + assert specfile_cls is spack.spec.SpecfileLatest