mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Replace pkg_resources with importlib solution (#450)
This commit is contained in:
parent
1ba3bd9d07
commit
e23b091c99
2 changed files with 16 additions and 8 deletions
|
|
@ -1,7 +1,15 @@
|
|||
from pkg_resources import DistributionNotFound, get_distribution
|
||||
|
||||
try:
|
||||
__version__ = get_distribution("django-auditlog").version
|
||||
except DistributionNotFound:
|
||||
# package is not installed
|
||||
pass
|
||||
from importlib.metadata import version # New in Python 3.8
|
||||
except ImportError:
|
||||
from pkg_resources import ( # from setuptools, deprecated
|
||||
DistributionNotFound,
|
||||
get_distribution,
|
||||
)
|
||||
|
||||
try:
|
||||
__version__ = get_distribution("django-auditlog").version
|
||||
except DistributionNotFound:
|
||||
# package is not installed
|
||||
pass
|
||||
else:
|
||||
__version__ = version("django-auditlog")
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import os
|
|||
import sys
|
||||
from datetime import date
|
||||
|
||||
from pkg_resources import get_distribution
|
||||
from auditlog import __version__
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ project = "django-auditlog"
|
|||
author = "Jan-Jelle Kester and contributors"
|
||||
copyright = f"2013-{date.today().year}, {author}"
|
||||
|
||||
release = get_distribution("django-auditlog").version
|
||||
release = __version__
|
||||
# for example take major/minor
|
||||
version = ".".join(release.split(".")[:2])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue