Skip to content

Commit 3e05d6e

Browse files
authored
fix the detection of backend entrypoints (#5931)
1 parent 1d28329 commit 3e05d6e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

ci/requirements/py37-bare-minimum.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ dependencies:
1313
- numpy=1.18
1414
- pandas=1.1
1515
- typing_extensions=3.7
16+
- importlib-metadata=2.0

ci/requirements/py37-min-all-deps.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies:
2424
- hdf5=1.10
2525
- hypothesis
2626
- iris=2.4
27+
- importlib-metadata=2.0
2728
- lxml=4.6 # Optional dep of pydap
2829
- matplotlib-base=3.3
2930
- nc-time-axis=1.2

doc/whats-new.rst

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Deprecations
3131

3232
Bug fixes
3333
~~~~~~~~~
34+
- Fix a regression in the detection of the backend entrypoints (:issue:`5930`, :pull:`5931`)
35+
By `Justus Magin <https://github.com/keewis>`_.
3436

3537
Documentation
3638
~~~~~~~~~~~~~

xarray/backends/plugins.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from .common import BACKEND_ENTRYPOINTS, BackendEntrypoint
77

88
try:
9-
from importlib.metadata import Distribution
9+
from importlib.metadata import entry_points
1010
except ImportError:
1111
# if the fallback library is missing, we are doomed.
12-
from importlib_metadata import Distribution # type: ignore[no-redef]
12+
from importlib_metadata import entry_points # type: ignore[no-redef]
1313

1414

1515
STANDARD_BACKENDS_ORDER = ["netcdf4", "h5netcdf", "scipy"]
@@ -99,11 +99,7 @@ def build_engines(entrypoints):
9999

100100
@functools.lru_cache(maxsize=1)
101101
def list_engines():
102-
entrypoints = (
103-
entry_point
104-
for entry_point in Distribution.from_name("xarray").entry_points
105-
if entry_point.module == "xarray.backends"
106-
)
102+
entrypoints = entry_points().get("xarray.backends", ())
107103
return build_engines(entrypoints)
108104

109105

0 commit comments

Comments
 (0)