mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-01 01:25:07 +08:00
✨ Feature: 使用 importlib.metadata
替换 pkg_resources
(#1388)
Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
This commit is contained in:
parent
0bc8a39578
commit
4355025f87
@ -39,6 +39,7 @@ FrontMatter:
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import importlib
|
import importlib
|
||||||
|
from importlib.metadata import version
|
||||||
from typing import Any, Dict, Type, Optional
|
from typing import Any, Dict, Type, Optional
|
||||||
|
|
||||||
import loguru
|
import loguru
|
||||||
@ -51,14 +52,9 @@ from nonebot.config import Env, Config
|
|||||||
from nonebot.drivers import Driver, ReverseDriver, combine_driver
|
from nonebot.drivers import Driver, ReverseDriver, combine_driver
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
__version__ = version("nonebot2")
|
||||||
|
|
||||||
_dist: pkg_resources.Distribution = pkg_resources.get_distribution("nonebot2")
|
|
||||||
__version__ = _dist.version
|
|
||||||
VERSION = _dist.parsed_version
|
|
||||||
except Exception: # pragma: no cover
|
except Exception: # pragma: no cover
|
||||||
__version__ = None
|
__version__ = None
|
||||||
VERSION = None
|
|
||||||
|
|
||||||
_driver: Optional[Driver] = None
|
_driver: Optional[Driver] = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user