diff --git a/django_downloadview/__init__.py b/django_downloadview/__init__.py index b0a9d8d..cfbe9cb 100644 --- a/django_downloadview/__init__.py +++ b/django_downloadview/__init__.py @@ -1,7 +1,7 @@ """Serve files with Django and reverse proxies.""" from django_downloadview.api import * # NoQA -import pkg_resources +import importlib.metadata #: Module version, as defined in PEP-0396. -__version__ = pkg_resources.get_distribution(__package__.replace("-", "_")).version +__version__ = importlib.metadata.version(__package__.replace("-", "_")) diff --git a/docs/conf.py b/docs/conf.py index a91a711..9e4b80a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ """django-downloadview documentation build configuration file.""" import os import re -from pkg_resources import get_distribution + +import importlib.metadata # Minimal Django settings. Required to use sphinx.ext.autodoc, because # django-downloadview depends on Django... @@ -48,7 +49,7 @@ # built documents. # The full version, including alpha/beta/rc tags. -release = get_distribution("django-downloadview").version +release = importlib.metadata.version("django-downloadview") # The short X.Y version. version = '.'.join(release.split('.')[:2]) diff --git a/setup.py b/setup.py index 5c5cb8b..aeb4fd6 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,6 @@ install_requires=[ # BEGIN requirements "Django>=4.2", - "setuptools", "requests", # END requirements ], diff --git a/tests/packaging.py b/tests/packaging.py index b8fbced..42e9efe 100644 --- a/tests/packaging.py +++ b/tests/packaging.py @@ -24,22 +24,14 @@ def test_version_present(self): self.fail("django_downloadview package has no __version__.") def test_version_match(self): - """django_downloadview.__version__ matches pkg_resources info.""" - try: - import pkg_resources - except ImportError: - self.fail( - "Cannot import pkg_resources module. It is part of " - "setuptools, which is a dependency of " - "django_downloadview." - ) - distribution = pkg_resources.get_distribution("django-downloadview") + """django_downloadview.__version__ matches importlib metadata.""" + distribution = importlib.metadata.distribution("django-downloadview") installed_version = distribution.version self.assertEqual( installed_version, self.get_version(), "Version mismatch: django_downloadview.__version__ " - 'is "%s" whereas pkg_resources tells "%s". ' + 'is "%s" whereas importlib.metadata tells "%s". ' "You may need to run ``make develop`` to update the " "installed version in development environment." % (self.get_version(), installed_version),