Replace pkg_resources with importlib (#462)

This commit is contained in:
pi-slh 2023-05-25 20:12:15 +10:00 committed by GitHub
parent 2b41383745
commit aad7d2ad76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

2
poetry.lock generated
View File

@ -1868,4 +1868,4 @@ compiler = ["black", "isort", "jinja2"]
[metadata]
lock-version = "2.0"
python-versions = "^3.7"
content-hash = "f9503e42026d0807dc3ed344b5f8e6fa3f1c7ffa9c66b086de929aefaa8cb8c6"
content-hash = "58b357685be67e8852b589ee0df3011b37dc1a2460ece732c0fa4c922f62bddd"

View File

@ -15,6 +15,7 @@ packages = [
python = "^3.7"
black = { version = ">=19.3b0", optional = true }
grpclib = "^0.4.1"
importlib-metadata = { version = ">=1.6.0", python = "<3.8" }
jinja2 = { version = ">=3.0.3", optional = true }
python-dateutil = "^2.8"
isort = {version = "^5.11.5", optional = true}

View File

@ -1,4 +1,7 @@
from pkg_resources import get_distribution
try:
from importlib import metadata
except ImportError: # for Python<3.8
import importlib_metadata as metadata # type: ignore
__version__ = get_distribution("betterproto").version
__version__ = metadata.version("betterproto")