python: replace pkg_resources with importlib.metadata

Use of pkg_resources is discouraged in favor of importlib.resources,
importlib.metadata, and their backports.
This commit is contained in:
Robert Schütz
2023-02-20 09:29:38 -08:00
committed by Robert Schütz
parent 999a9550f5
commit d3f4654d4b
2 changed files with 7 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ classifiers = [
dependencies = [ dependencies = [
"cffi>=1.0.0", "cffi>=1.0.0",
"imap-tools", "imap-tools",
"importlib_metadata;python_version<'3.8'",
"pluggy", "pluggy",
"requests", "requests",
] ]

View File

@@ -1,6 +1,9 @@
import sys import sys
from pkg_resources import DistributionNotFound, get_distribution if sys.version_info >= (3, 8):
from importlib.metadata import PackageNotFoundError, version
else:
from importlib_metadata import PackageNotFoundError, version
from . import capi, events, hookspec # noqa from . import capi, events, hookspec # noqa
from .account import Account, get_core_info # noqa from .account import Account, get_core_info # noqa
@@ -11,8 +14,8 @@ from .hookspec import account_hookimpl, global_hookimpl # noqa
from .message import Message # noqa from .message import Message # noqa
try: try:
__version__ = get_distribution(__name__).version __version__ = version(__name__)
except DistributionNotFound: except PackageNotFoundError:
# package is not installed # package is not installed
__version__ = "0.0.0.dev0-unknown" __version__ = "0.0.0.dev0-unknown"