diff --git a/CHANGES.rst b/CHANGES.rst index a4e63abe..4a6e0e9b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,9 @@ Changelog for zest.releaser 9.1.4 (unreleased) ------------------ -- Nothing changed yet. +- Fixed version handling documentation to use ``importlib`` instead of + ``pkg_resources``. + [reinout] 9.1.3 (2024-02-07) diff --git a/doc/source/versions.rst b/doc/source/versions.rst index 9acb2f34..bbc19680 100644 --- a/doc/source/versions.rst +++ b/doc/source/versions.rst @@ -83,14 +83,13 @@ discussion. - The version in the ``setup.py`` is the real version. - Add a ``__version__`` attribute in your main module. Often this will be an - ``__init__.py``. Set this version attribute with ``pkg_resources``, which is - automatically installed as part of setuptools/distribute. Here's `the code - `_ + ``__init__.py``. Set this version attribute with ``importlib.metadata``. Here's `the + code `_ from ``zest/releaser/__init__.py``:: - import pkg_resources + from importlib.metadata import version - __version__ = pkg_resources.get_distribution("zest.releaser").version + __version__ = version("zest.releaser") This way you can do:: diff --git a/zest/releaser/__init__.py b/zest/releaser/__init__.py index 848a6675..e1b5ed25 100644 --- a/zest/releaser/__init__.py +++ b/zest/releaser/__init__.py @@ -1,6 +1,5 @@ from colorama import init - -import pkg_resources +from importlib.metadata import version # Initialize colorized output. Set it to reset after each print, so @@ -9,4 +8,4 @@ # but it looks like it already does that itself. init(autoreset=True) -__version__ = pkg_resources.get_distribution("zest.releaser").version +__version__ = version("zest.releaser")