Skip to content

Commit

Permalink
leverage importlib.metadata in docs/conf.py (aio-libs#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-keller committed Aug 21, 2024
1 parent 7d73151 commit 9a963f4
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,19 @@
#
# needs_sphinx = '1.0'

import pathlib
import importlib.metadata
import re

_docs_path = pathlib.Path(__file__).parent
_version_path = _docs_path / '../aiobotocore/__init__.py'


with _version_path.open() as fp:
try:
_version_info = re.search(
r"^__version__ = '"
r"(?P<major>\d+)"
r"\.(?P<minor>\d+)"
r"\.(?P<patch>\d+)"
r"(?P<tag>.*)?'$",
fp.read(),
re.M,
).groupdict()
except IndexError:
raise RuntimeError('Unable to determine version.')
try:
_version_info = re.fullmatch(
r"(?P<major>\d+)"
r"\.(?P<minor>\d+)"
r"\.(?P<patch>\d+)"
r"(?P<tag>.*)?",
importlib.metadata.version('aiobotocore'),
).groupdict()
except IndexError:
raise RuntimeError('Unable to determine version.')

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
Expand Down

0 comments on commit 9a963f4

Please sign in to comment.