Skip to content

Commit 5439c00

Browse files
committed
Replaced usages of the deprecated pkg_resources
(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.
1 parent cf35f61 commit 5439c00

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

docs/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
# serve to show the default.
1212
import os
1313
import sys
14-
15-
from pkg_resources import get_distribution
14+
from importlib import metadata
1615

1716
# If extensions (or modules to document with autodoc) are in another directory,
1817
# add these directories to sys.path here. If the directory is relative to the
@@ -48,7 +47,7 @@
4847
# |version| and |release|, also used in various other places throughout the
4948
# built documents.
5049
#
51-
release = get_distribution("django-simple-history").version
50+
release = metadata.version("django-simple-history")
5251
# for example take major/minor
5352
version = ".".join(release.split(".")[:2])
5453

simple_history/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pkg_resources import DistributionNotFound, get_distribution
1+
from importlib import metadata
22

33
try:
4-
__version__ = get_distribution(__name__).version
5-
except DistributionNotFound:
4+
__version__ = metadata.version(__name__)
5+
except metadata.PackageNotFoundError:
66
# package is not installed
77
pass
88

0 commit comments

Comments
 (0)