From f8b00a88f2c448a8d7d9e91a54bbf2e1a9d96e4e Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 12 Nov 2024 12:40:04 -0800 Subject: [PATCH] Replace pbr and pkg_resource version info with importlib.metadata This updates zuul-sphinx to retrieve version info from package metadata using importlib.metadata instead of the now removed pkg_resources library. This is necessary to run doc builds on top of python3.12 which removed setuptools and pkg_resources by default. An altnerative would be to explicitly require setuptools as a dependency but stdlib importlib should be sufficient so we don't bother. Change-Id: I5d73e7cc728188e7978e30eb5eb53d73e74b9ce2 --- zuul_sphinx/version.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/zuul_sphinx/version.py b/zuul_sphinx/version.py index b57c528..e0c7831 100644 --- a/zuul_sphinx/version.py +++ b/zuul_sphinx/version.py @@ -14,17 +14,15 @@ import json -import pbr.version -import pkg_resources +from importlib import metadata as importlib_metadata -version_info = pbr.version.VersionInfo('zuul-sphinx') -release_string = version_info.release_string() +zuul_sphinx_distribution = importlib_metadata.distribution('zuul-sphinx') +release_string = zuul_sphinx_distribution.version is_release = None git_version = None try: - _metadata = json.loads( - pkg_resources.get_distribution('zuul-sphinx').get_metadata('pbr.json')) + _metadata = json.loads(zuul_distribution.read_text('pbr.json')) if _metadata: is_release = _metadata['is_release'] git_version = _metadata['git_version']