Skip to content

Commit 8969e7b

Browse files
authored
Use importlib.metadata instead of pkg_resources (#446)
1 parent 92deda1 commit 8969e7b

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

pysteps/io/interface.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
import importlib
1616

17-
from pkg_resources import iter_entry_points
17+
from importlib.metadata import entry_points
1818

1919
from pysteps import io
2020
from pysteps.decorators import postprocess_import
@@ -49,17 +49,7 @@ def discover_importers():
4949
The importers found are added to the `pysteps.io.interface_importer_methods`
5050
dictionary containing the available importers.
5151
"""
52-
53-
# The pkg resources needs to be reload to detect new packages installed during
54-
# the execution of the python application. For example, when the plugins are
55-
# installed during the tests
56-
import pkg_resources
57-
58-
importlib.reload(pkg_resources)
59-
60-
for entry_point in pkg_resources.iter_entry_points(
61-
group="pysteps.plugins.importers", name=None
62-
):
52+
for entry_point in entry_points(group="pysteps.plugins.importers"):
6353
_importer = entry_point.load()
6454

6555
importer_function_name = _importer.__name__
@@ -73,14 +63,14 @@ def discover_importers():
7363
RuntimeWarning(
7464
f"The importer identifier '{importer_short_name}' is already available in"
7565
"'pysteps.io.interface._importer_methods'.\n"
76-
f"Skipping {entry_point.module_name}:{'.'.join(entry_point.attrs)}"
66+
f"Skipping {entry_point.module}:{entry_point.attr}"
7767
)
7868

7969
if hasattr(importers, importer_function_name):
8070
RuntimeWarning(
8171
f"The importer function '{importer_function_name}' is already an attribute"
8272
"of 'pysteps.io.importers`.\n"
83-
f"Skipping {entry_point.module_name}:{'.'.join(entry_point.attrs)}"
73+
f"Skipping {entry_point.module}:{entry_point.attr}"
8474
)
8575
else:
8676
setattr(importers, importer_function_name, _importer)

0 commit comments

Comments
 (0)