🐛 fix import error if setuptools not installed (#1116)

Fix: 修复 setuptools 未安装导致 ImportError
This commit is contained in:
Ju4tCode 2022-08-01 10:52:15 +08:00 committed by GitHub
parent 6e98ac031c
commit 71bf1d1147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,8 +40,6 @@ FrontMatter:
import importlib
from typing import Any, Dict, Type, Optional
import pkg_resources
from nonebot.adapters import Bot
from nonebot.utils import escape_tag
from nonebot.config import Env, Config
@ -49,10 +47,12 @@ from nonebot.log import logger, default_filter
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
except pkg_resources.DistributionNotFound: # pragma: no cover
except Exception: # pragma: no cover
__version__ = None
VERSION = None