diff --git a/docs/conf.py b/docs/conf.py index 0d47d51..fbab4aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,7 +11,7 @@ # serve to show the default. import os -from pkg_resources import get_distribution +import importlib.metadata # 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 @@ -49,7 +49,8 @@ parent_dir = os.path.dirname(os.path.dirname(__file__)) # |version| and |release|, also used in various other places throughout the # built documents. # -release = get_distribution('django-model-utils').version +release = importlib.metadata.version('django-model-utils') + # for example take major/minor version = '.'.join(release.split('.')[:2]) diff --git a/model_utils/__init__.py b/model_utils/__init__.py index 691cf5c..8b02a0e 100644 --- a/model_utils/__init__.py +++ b/model_utils/__init__.py @@ -1,10 +1,10 @@ -from pkg_resources import DistributionNotFound, get_distribution +import importlib.metadata from .choices import Choices # noqa:F401 from .tracker import FieldTracker, ModelTracker # noqa:F401 try: - __version__ = get_distribution("django-model-utils").version -except DistributionNotFound: # pragma: no cover + __version__ = importlib.metadata.version('django-model-utils') +except importlib.metadata.PackageNotFoundError: # pragma: no cover # package is not installed __version__ = None