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

fix the detection of backend entrypoints #5931

Merged
merged 4 commits into from
Nov 3, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/requirements/py37-bare-minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dependencies:
- numpy=1.18
- pandas=1.1
- typing_extensions=3.7
- importlib-metadata=2.0
1 change: 1 addition & 0 deletions ci/requirements/py37-min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Deprecations

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

Internal Changes
~~~~~~~~~~~~~~~~
Expand Down
10 changes: 3 additions & 7 deletions xarray/backends/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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)


Expand Down