mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +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
@@ -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",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user