From aa584381b24d8007a5831d398e9e72fa5090dcf9 Mon Sep 17 00:00:00 2001 From: keewis Date: Wed, 3 Nov 2021 17:55:54 +0100 Subject: [PATCH] fix the detection of backend entrypoints (#5931) --- ci/requirements/py37-bare-minimum.yml | 1 + ci/requirements/py37-min-all-deps.yml | 1 + doc/whats-new.rst | 2 ++ xarray/backends/plugins.py | 10 +++------- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ci/requirements/py37-bare-minimum.yml b/ci/requirements/py37-bare-minimum.yml index f9148d6dfd0..620b5057d50 100644 --- a/ci/requirements/py37-bare-minimum.yml +++ b/ci/requirements/py37-bare-minimum.yml @@ -13,3 +13,4 @@ dependencies: - numpy=1.18 - pandas=1.1 - typing_extensions=3.7 + - importlib-metadata=2.0 diff --git a/ci/requirements/py37-min-all-deps.yml b/ci/requirements/py37-min-all-deps.yml index 2d5a0f4e8d9..e62987dd31a 100644 --- a/ci/requirements/py37-min-all-deps.yml +++ b/ci/requirements/py37-min-all-deps.yml @@ -24,6 +24,7 @@ dependencies: - hdf5=1.10 - hypothesis - iris=2.4 + - importlib-metadata=2.0 - lxml=4.6 # Optional dep of pydap - matplotlib-base=3.3 - nc-time-axis=1.2 diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 06d9ea8ed40..be39cd387d8 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -31,6 +31,8 @@ Deprecations Bug fixes ~~~~~~~~~ +- Fix a regression in the detection of the backend entrypoints (:issue:`5930`, :pull:`5931`) + By `Justus Magin `_. Documentation ~~~~~~~~~~~~~ diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index b71ca7be55c..bcaee498b90 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -6,10 +6,10 @@ from .common import BACKEND_ENTRYPOINTS, BackendEntrypoint try: - from importlib.metadata import Distribution + from importlib.metadata import entry_points except ImportError: # if the fallback library is missing, we are doomed. - from importlib_metadata import Distribution # type: ignore[no-redef] + from importlib_metadata import entry_points # type: ignore[no-redef] STANDARD_BACKENDS_ORDER = ["netcdf4", "h5netcdf", "scipy"] @@ -99,11 +99,7 @@ def build_engines(entrypoints): @functools.lru_cache(maxsize=1) def list_engines(): - entrypoints = ( - entry_point - for entry_point in Distribution.from_name("xarray").entry_points - if entry_point.module == "xarray.backends" - ) + entrypoints = entry_points().get("xarray.backends", ()) return build_engines(entrypoints)