From 95a780cbdeebe31b197ce9cfba86a613c70d9b9f Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Sun, 22 Jan 2023 20:52:20 -0700 Subject: [PATCH] Replace pkg_resources use with importlib.metadata --- docs/conf.py | 8 ++++++-- setup.cfg | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 392bde96..bb1b1f51 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,11 @@ # sys.path.append(os.path.abspath('some/directory')) import datetime -import pkg_resources + +try: + from importlib.metadata import version as metadata_version +except ImportError: + from importlib_metadata import version as metadata_version import pylons_sphinx_themes # General configuration @@ -53,7 +57,7 @@ # other places throughout the built documents. # # The short X.Y version. -version = pkg_resources.get_distribution("waitress").version +version = metadata_version("waitress") # The full version, including alpha/beta/rc tags. release = version diff --git a/setup.cfg b/setup.cfg index 672ef9d6..65625dce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -58,6 +58,7 @@ docs = Sphinx>=1.8.1 docutils pylons-sphinx-themes>=1.0.9 + importlib-metadata; python_version < "3.8" [tool:pytest] python_files = test_*.py