From dcaa85c61978fe1ef095fa8ebc5569629352bcea Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 19 Sep 2023 07:28:29 -0500 Subject: [PATCH] De-duplicate the version numbers in the project --- docs/conf.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0deacc5..c8ba9ae 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,14 +1,26 @@ import pathlib import sys -basedir = pathlib.Path(__file__).parent.parent +src_directory = (pathlib.Path(__file__).parent.parent / "src").resolve() +sys.path.insert(0, str(src_directory)) + + +# Extract the current version from the source. +def get_version(): + """Get the version and release from the source code.""" + + text = (src_directory / "cachetools/__init__.py").read_text() + for line in text.splitlines(): + if not line.strip().startswith("__version__"): + continue + full_version = line.partition("=")[2].strip().strip("\"'") + partial_version = ".".join(full_version.split(".")[:2]) + return full_version, partial_version -sys.path.insert(0, str((basedir / "src").resolve())) project = "cachetools" copyright = "2014-2023 Thomas Kemmer" -version = "5.3" -release = "5.3.1" +release, version = get_version() extensions = [ "sphinx.ext.autodoc",