Feature: 使用 importlib.metadata 替换 pkg_resources (#1388)

Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
This commit is contained in:
Akirami 2022-11-12 18:22:16 +08:00 committed by GitHub
parent 0bc8a39578
commit 4355025f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,7 @@ FrontMatter:
import os
import importlib
from importlib.metadata import version
from typing import Any, Dict, Type, Optional
import loguru
@ -51,14 +52,9 @@ from nonebot.config import Env, Config
from nonebot.drivers import Driver, ReverseDriver, combine_driver
try:
import pkg_resources
_dist: pkg_resources.Distribution = pkg_resources.get_distribution("nonebot2")
__version__ = _dist.version
VERSION = _dist.parsed_version
__version__ = version("nonebot2")
except Exception: # pragma: no cover
__version__ = None
VERSION = None
_driver: Optional[Driver] = None