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
This commit is contained in:
parent
f51dd26d25
commit
f8b00a88f2
@ -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']
|
||||
|
Loading…
Reference in New Issue
Block a user