Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update lower pin to importlib_metadata for all python versions #1260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
-------------------

Expand Down
11 changes: 6 additions & 5 deletions asdf/entry_points.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 6 additions & 7 deletions asdf/tests/test_entry_points.py
Original file line number Diff line number Diff line change
@@ -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

braingram marked this conversation as resolved.
Show resolved Hide resolved
from asdf import entry_points
from asdf._version import version as asdf_package_version
from asdf.exceptions import AsdfWarning
Expand Down
14 changes: 7 additions & 7 deletions asdf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
braingram marked this conversation as resolved.
Show resolved Hide resolved
'jmespath >=0.6.2',
'jsonschema >=4.0.1',
'numpy >=1.18',
Expand Down