Skip to content

Commit 777fc70

Browse files
authored
Merge pull request #285 from kurtmckee/de-duplicate-versions
De-duplicate the version numbers in the project
2 parents 44a913d + dcaa85c commit 777fc70

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

docs/conf.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
import pathlib
22
import sys
33

4-
basedir = pathlib.Path(__file__).parent.parent
4+
src_directory = (pathlib.Path(__file__).parent.parent / "src").resolve()
5+
sys.path.insert(0, str(src_directory))
6+
7+
8+
# Extract the current version from the source.
9+
def get_version():
10+
"""Get the version and release from the source code."""
11+
12+
text = (src_directory / "cachetools/__init__.py").read_text()
13+
for line in text.splitlines():
14+
if not line.strip().startswith("__version__"):
15+
continue
16+
full_version = line.partition("=")[2].strip().strip("\"'")
17+
partial_version = ".".join(full_version.split(".")[:2])
18+
return full_version, partial_version
519

6-
sys.path.insert(0, str((basedir / "src").resolve()))
720

821
project = "cachetools"
922
copyright = "2014-2023 Thomas Kemmer"
10-
version = "5.3"
11-
release = "5.3.1"
23+
release, version = get_version()
1224

1325
extensions = [
1426
"sphinx.ext.autodoc",

0 commit comments

Comments
 (0)