Skip to content

Commit

Permalink
Replaced usages of the deprecated pkg_resources
Browse files Browse the repository at this point in the history
(It seems like after the last commit added `python = 3.12` to `tox.ini`,
that version was actually being used, which made the tests fail against
Python 3.12-dev.)

As of Python 3.12, the `pkg_resources` package is no longer provided
(see https://docs.python.org/3.13/whatsnew/3.12.html#removed).
The package has been deprecated in favor of `importlib.metadata
(see the "Attention" notice at the top of
https://setuptools.pypa.io/en/latest/pkg_resources.html),
and the replacement for `pkg_resources.get_distribution()` is
`importlib.metadata.version()` (according to
googleapis/python-api-core#27 (comment)).
See also https://docs.python.org/3/library/importlib.metadata.html#distribution-versions.
  • Loading branch information
ddabble committed Jul 4, 2023
1 parent cf35f61 commit 3cf1e54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os
import sys

from pkg_resources import get_distribution
from importlib import 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
Expand Down Expand Up @@ -48,7 +48,7 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
release = get_distribution("django-simple-history").version
release = metadata.version("django-simple-history")
# for example take major/minor
version = ".".join(release.split(".")[:2])

Expand Down
6 changes: 3 additions & 3 deletions simple_history/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pkg_resources import DistributionNotFound, get_distribution
from importlib import metadata

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
__version__ = metadata.version(__name__)
except metadata.PackageNotFoundError:
# package is not installed
pass

Expand Down

0 comments on commit 3cf1e54

Please sign in to comment.