diff --git a/asdf/_core/_extensions.py b/asdf/_core/_extensions.py index 205fd23f0..9c7303100 100644 --- a/asdf/_core/_extensions.py +++ b/asdf/_core/_extensions.py @@ -1,4 +1,5 @@ from asdf.extension import ManifestExtension +from asdf.versioning import supported_versions from ._converters.complex import ComplexConverter from ._converters.constant import ConstantConverter @@ -37,15 +38,7 @@ ] -MANIFEST_URIS = [ - "asdf://asdf-format.org/core/manifests/core-1.0.0", - "asdf://asdf-format.org/core/manifests/core-1.1.0", - "asdf://asdf-format.org/core/manifests/core-1.2.0", - "asdf://asdf-format.org/core/manifests/core-1.3.0", - "asdf://asdf-format.org/core/manifests/core-1.4.0", - "asdf://asdf-format.org/core/manifests/core-1.5.0", - "asdf://asdf-format.org/core/manifests/core-1.6.0", -] +MANIFEST_URIS = [f"asdf://asdf-format.org/core/manifests/core-{version}" for version in supported_versions] EXTENSIONS = [ diff --git a/asdf/versioning.py b/asdf/versioning.py index 666f8eafc..2255a1c5d 100644 --- a/asdf/versioning.py +++ b/asdf/versioning.py @@ -3,6 +3,7 @@ of the ASDF spec. """ +import importlib.resources from functools import total_ordering import yaml @@ -143,15 +144,19 @@ def __hash__(self): return super().__hash__() -supported_versions = [ - AsdfVersion("1.0.0"), - AsdfVersion("1.1.0"), - AsdfVersion("1.2.0"), - AsdfVersion("1.3.0"), - AsdfVersion("1.4.0"), - AsdfVersion("1.5.0"), - AsdfVersion("1.6.0"), -] +def _find_asdf_standard_version_map_versions(): + # each version has a map + version_map_filenames = ( + importlib.resources.files("asdf_standard") / "resources" / "schemas" / "stsci.edu" / "asdf" + ).glob("version_map-*.yaml") + versions = [] + for version_map_filename in version_map_filenames: + _, version_string = version_map_filename.with_suffix("").name.split("-", 1) + versions.append(AsdfVersion(version_string)) + return sorted(versions) + + +supported_versions = _find_asdf_standard_version_map_versions() default_version = AsdfVersion("1.5.0")