diff --git a/src/orion/core/utils/__init__.py b/src/orion/core/utils/__init__.py index 48e5179a5..31411ce6a 100644 --- a/src/orion/core/utils/__init__.py +++ b/src/orion/core/utils/__init__.py @@ -9,6 +9,7 @@ import logging import os import signal +import sys from abc import ABCMeta from collections import defaultdict from contextlib import contextmanager @@ -16,7 +17,11 @@ from importlib import import_module from tempfile import NamedTemporaryFile -import pkg_resources +if sys.version_info >= (3, 10): + from importlib.metadata import entry_points +else: + from pkg_resources import iter_entry_points + log = logging.getLogger(__name__) @@ -72,7 +77,15 @@ def _import_modules(cls): # base = import_module(cls.__base__.__module__) # Get types advertised through entry points! - for entry_point in pkg_resources.iter_entry_points(cls.__name__): + if sys.version_info >= (3, 10): + entry_point_iterable = ( + entry_point + for entry_point in entry_points() + if entry_point.group == cls.__name__ + ) + else: + entry_point_iterable = iter_entry_points(cls.__name__) + for entry_point in entry_point_iterable: entry_point.load() assert entry_point.dist is not None log.debug(