Skip to content

Commit 3f8a883

Browse files
committed
no longer use pkg_resource
1 parent 031e567 commit 3f8a883

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,6 @@
241241
# How to display URL addresses: 'footnote', 'no', or 'inline'.
242242
#texinfo_show_urls = 'footnote'
243243

244-
import pkg_resources
245-
version = pkg_resources.get_distribution("irc3").version
244+
from importlib.metadata import version
245+
version = version("irc3")
246246
release = version

irc3/base.py

+8-22
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@
55
import signal
66
import logging
77
import logging.config
8+
from importlib import metadata
89
from . import utils
910
from . import config
1011
from .compat import asyncio
1112
from .compat import reload_module
1213
from collections import defaultdict
1314

14-
try:
15-
import pkg_resources
16-
from pkg_resources import iter_entry_points
17-
HAS_PKG_RESOURCES = True
18-
except ImportError: # pragma: no cover
19-
HAS_PKG_RESOURCES = False
20-
version = ''
21-
else:
22-
try:
23-
version = pkg_resources.get_distribution('irc3').version
24-
except pkg_resources.DistributionNotFound:
25-
version = ''
15+
16+
version = metadata.version('irc3')
2617

2718

2819
class Registry:
@@ -200,16 +191,11 @@ def include(self, *modules, **kwargs):
200191
try:
201192
module = utils.maybedotted(module)
202193
except LookupError as exc:
203-
if HAS_PKG_RESOURCES:
204-
entry_points = iter_entry_points(
205-
'irc3.loader',
206-
module
207-
)
208-
try:
209-
module = next(entry_points).load()
210-
except StopIteration:
211-
raise exc
212-
else:
194+
try:
195+
(module,) = metadata.entry_points(group='irc3.loader',
196+
name=module)
197+
module = module.load()
198+
except (ImportError, ValueError):
213199
raise exc
214200
# we have to manualy check for plugins. venusian no longer
215201
# support to attach both a class and methods

0 commit comments

Comments
 (0)