Replace deprecated pkg_resources with importlib.metadata

This commit is contained in:
Dmitry Shachnev 2026-04-08 13:43:03 +03:00
parent f58bbef27e
commit 234fdc0383
2 changed files with 5 additions and 5 deletions

View file

@ -1,8 +1,8 @@
from pkg_resources import get_distribution, DistributionNotFound
from importlib.metadata import PackageNotFoundError, version
try:
__version__ = get_distribution("django-authority").version
except DistributionNotFound:
__version__ = version("django-authority")
except PackageNotFoundError:
# package is not installed
pass

View file

@ -11,7 +11,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
from pkg_resources import get_distribution
from importlib.metadata import version
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@ -46,7 +46,7 @@ copyright = u"2009-2020, Jannis Leidel"
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = get_distribution("django-authority").version
release = version("django-authority")
# The short X.Y version.
version = ".".join(release.split(".")[:2])