mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 07:32:12 +03:00
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:
committed by
Robert Schütz
parent
999a9550f5
commit
d3f4654d4b
@@ -1,6 +1,9 @@
|
||||
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 .account import Account, get_core_info # noqa
|
||||
@@ -11,8 +14,8 @@ from .hookspec import account_hookimpl, global_hookimpl # noqa
|
||||
from .message import Message # noqa
|
||||
|
||||
try:
|
||||
__version__ = get_distribution(__name__).version
|
||||
except DistributionNotFound:
|
||||
__version__ = version(__name__)
|
||||
except PackageNotFoundError:
|
||||
# package is not installed
|
||||
__version__ = "0.0.0.dev0-unknown"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user