Skip to content

Commit

Permalink
Remove deprecated pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilGirdhar committed Oct 11, 2023
1 parent 0bb9051 commit 3d15289
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/orion/core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
import logging
import os
import signal
import sys
from abc import ABCMeta
from collections import defaultdict
from contextlib import contextmanager
from glob import glob
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__)

Expand Down Expand Up @@ -72,14 +77,22 @@ 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_points(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(
"Found a %s %s from distribution: %s=%s",
entry_point.name,
cls.__name__,
entry_point.dist.project_name,
(
entry_point.dist.name
if sys.version_info >= (3, 10)
else entry_point.dist.project_name
),
entry_point.dist.version,
)

Expand Down

0 comments on commit 3d15289

Please sign in to comment.