diff --git a/CHANGES.rst b/CHANGES.rst index 745ddb31f..19ff7af33 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +2.14.3 (unreleased) +------------------- + +The ASDF Standard is at v1.6.0 + +- Use importlib_metadata for all python versions [#1260] + 2.14.2 (2022-12-05) ------------------- diff --git a/asdf/entry_points.py b/asdf/entry_points.py index 30b673c15..896b8aff0 100644 --- a/asdf/entry_points.py +++ b/asdf/entry_points.py @@ -1,10 +1,11 @@ -import sys import warnings -if sys.version_info < (3, 10): - from importlib_metadata import entry_points -else: - from importlib.metadata import entry_points +# The standard library importlib.metadata returns duplicate entrypoints +# for all python versions up to and including 3.11 +# https://github.com/python/importlib_metadata/issues/410#issuecomment-1304258228 +# see PR https://github.com/asdf-format/asdf/pull/1260 +# see issue https://github.com/asdf-format/asdf/issues/1254 +from importlib_metadata import entry_points from .exceptions import AsdfWarning from .extension import ExtensionProxy diff --git a/asdf/tests/test_entry_points.py b/asdf/tests/test_entry_points.py index 3313e35b7..789ff238a 100644 --- a/asdf/tests/test_entry_points.py +++ b/asdf/tests/test_entry_points.py @@ -1,12 +1,11 @@ -import sys - +# The standard library importlib.metadata returns duplicate entrypoints +# for all python versions up to and including 3.11 +# https://github.com/python/importlib_metadata/issues/410#issuecomment-1304258228 +# see PR https://github.com/asdf-format/asdf/pull/1260 +# see issue https://github.com/asdf-format/asdf/issues/1254 +import importlib_metadata as metadata import pytest -if sys.version_info < (3, 10): - import importlib_metadata as metadata -else: - import importlib.metadata as metadata - from asdf import entry_points from asdf._version import version as asdf_package_version from asdf.exceptions import AsdfWarning diff --git a/asdf/util.py b/asdf/util.py index df8924975..4ecc83452 100644 --- a/asdf/util.py +++ b/asdf/util.py @@ -4,23 +4,23 @@ import math import re import struct -import sys import types from functools import lru_cache from importlib import metadata from urllib.request import pathname2url import numpy as np + +# The standard library importlib.metadata returns duplicate entrypoints +# for all python versions up to and including 3.11 +# https://github.com/python/importlib_metadata/issues/410#issuecomment-1304258228 +# see PR https://github.com/asdf-format/asdf/pull/1260 +# see issue https://github.com/asdf-format/asdf/issues/1254 +from importlib_metadata import packages_distributions from packaging.version import Version from . import constants -if sys.version_info < (3, 10): - from importlib_metadata import packages_distributions -else: - from importlib.metadata import packages_distributions - - # We're importing our own copy of urllib.parse because # we need to patch it to support asdf:// URIs, but it'd # be irresponsible to do this for all users of a diff --git a/docs/conf.py b/docs/conf.py index 8bc94c0af..1a1e9f659 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,13 +1,14 @@ from pathlib import Path import tomli -from sphinx_asdf.conf import * # noqa: F403 - -try: - from importlib.metadata import distribution -except ImportError: - from importlib_metadata import distribution +# The standard library importlib.metadata returns duplicate entrypoints +# for all python versions up to and including 3.11 +# https://github.com/python/importlib_metadata/issues/410#issuecomment-1304258228 +# see PR https://github.com/asdf-format/asdf/pull/1260 +# see issue https://github.com/asdf-format/asdf/issues/1254 +from importlib_metadata import distribution +from sphinx_asdf.conf import * # noqa: F403 # Get configuration information from `pyproject.toml` with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as configuration_file: diff --git a/pyproject.toml b/pyproject.toml index c439ac8b6..fc35c4b65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ 'asdf-transform-schemas >=0.2.2', 'asdf-unit-schemas >= 0.1.0', 'importlib_resources >=3; python_version <"3.9"', - 'importlib-metadata >=3; python_version <"3.10"', + 'importlib-metadata >=4.11.4', 'jmespath >=0.6.2', 'jsonschema >=4.0.1', 'numpy >=1.18',