Skip to content

Commit

Permalink
no longer use pkg_resource
Browse files Browse the repository at this point in the history
  • Loading branch information
gawel committed Jan 3, 2025
1 parent f216c72 commit 2761f29
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,6 @@
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

import pkg_resources
version = pkg_resources.get_distribution("irc3").version
from importlib.metadata import version
version = version("irc3")
release = version
32 changes: 13 additions & 19 deletions irc3/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@
import signal
import logging
import logging.config
from importlib import metadata
from . import utils
from . import config
from .compat import asyncio
from .compat import reload_module
from collections import defaultdict

try:
import pkg_resources
from pkg_resources import iter_entry_points
HAS_PKG_RESOURCES = True
except ImportError: # pragma: no cover
HAS_PKG_RESOURCES = False
version = ''
else:
try:
version = pkg_resources.get_distribution('irc3').version
except pkg_resources.DistributionNotFound:
version = ''

version = metadata.version('irc3')


class Registry:
Expand Down Expand Up @@ -200,14 +191,17 @@ def include(self, *modules, **kwargs):
try:
module = utils.maybedotted(module)
except LookupError as exc:
if HAS_PKG_RESOURCES:
entry_points = iter_entry_points(
'irc3.loader',
module
)
entry_points = metadata.entry_points()
entry_points = [
eps for eps in entry_points
if eps.group == 'irc3.loader'
and eps.name == module
]
if entry_points:
eps = entry_points[0]
try:
module = next(entry_points).load()
except StopIteration:
module = eps.load()
except ImportError:
raise exc
else:
raise exc
Expand Down

0 comments on commit 2761f29

Please sign in to comment.