Commit 2572e947 authored by Klaus Zimmermann's avatar Klaus Zimmermann
Browse files

Replace pkg_resources with importlib.metadata for entry points (closes #225)

parent cf550abf
......@@ -9,10 +9,10 @@ import logging
import os
import re
import string
import sys
from typing import Any, List, Mapping, Optional, Union
import iris
import pkg_resources
import xdg.BaseDirectory
import yaml
......@@ -20,6 +20,13 @@ from .index import Index
from .period import PeriodSpecification
if sys.version_info[:2] >= (3, 10):
# pylint: disable=no-name-in-module
from importlib.metadata import entry_points
else:
from importlib_metadata import entry_points
@dataclass
class CellMethod:
name: str
......@@ -355,9 +362,7 @@ class IndexCatalog:
def build_index_function(spec):
name = spec.name
candidates = list(
pkg_resources.iter_entry_points("climix.index_functions", name=name)
)
candidates = list(entry_points(group="climix.index_functions", name=name))
if len(candidates) == 0:
raise ValueError(f"No implementation found for index_function <{name}>")
elif len(candidates) > 1:
......
......@@ -36,6 +36,7 @@ setuptools.setup(
"dask>=2.4.0",
"dask-jobqueue",
"distributed>=2.4.0",
'importlib_metadata>=4.4; python_version < "2.10"',
"numpy",
"pyxdg",
"PyYAML",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment