diff --git a/auditlog/__init__.py b/auditlog/__init__.py index 50e8238..b758d0d 100644 --- a/auditlog/__init__.py +++ b/auditlog/__init__.py @@ -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") diff --git a/docs/source/conf.py b/docs/source/conf.py index 710a457..f6689fa 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -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])