From 8e983694df6fd64b96cd62c6439b7909d6234bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lukas=20Sp=C3=A4h?= Date: Thu, 22 May 2025 19:05:31 +0200 Subject: [PATCH 1/4] Take version from importing cpax instead of getting it from installed package that is not actually installed --- docs/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index cf5ac8c..3bf7989 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -9,12 +9,12 @@ import os import sys sys.path.insert(0, os.path.abspath('../../src')) -import importlib.metadata project = 'CPax' copyright = '2025, Jan Lukas Späh' author = 'Jan Lukas Späh' -release = importlib.metadata.version("cpax") +from cpax import __version__ +release = __version__ version = ".".join(release.split(".")[:2]) # -- General configuration --------------------------------------------------- From f4dcecf6b17875fcfaf95f157a827cf2997c7731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lukas=20Sp=C3=A4h?= Date: Sun, 8 Jun 2025 13:54:09 +0200 Subject: [PATCH 2/4] Move up import to adhere to style guidelines --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3bf7989..c691a68 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,12 +8,12 @@ import os import sys +from cpax import __version__ sys.path.insert(0, os.path.abspath('../../src')) project = 'CPax' copyright = '2025, Jan Lukas Späh' author = 'Jan Lukas Späh' -from cpax import __version__ release = __version__ version = ".".join(release.split(".")[:2]) From cd59a9a6da48f1dd97515b9b2e112f3faae414ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lukas=20Sp=C3=A4h?= Date: Sun, 8 Jun 2025 13:54:57 +0200 Subject: [PATCH 3/4] Wrap version import in try except --- docs/source/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index c691a68..bb49b87 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,7 +8,13 @@ import os import sys -from cpax import __version__ +try: + from cpax import __version__ +except (ImportError, AttributeError) as e: + raise RuntimeError( + "Failed to import `__version__` from the `cpax` package. Ensure that the `cpax` package is installed " + "and contains a `__version__` attribute." + ) from e sys.path.insert(0, os.path.abspath('../../src')) project = 'CPax' From 11cf3754984165340af8743dc75d6996a4377831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lukas=20Sp=C3=A4h?= Date: Sun, 8 Jun 2025 13:59:54 +0200 Subject: [PATCH 4/4] Install package during readthedocs building to allow version to be fetched dynamically --- .readthedocs.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0e0c698..5ddf090 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -15,6 +15,9 @@ sphinx: # declare the Python requirements required to build your documentation # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +# Install the package itself so that the version can be fetched dynamically during docs building (see docs/source/conf.py) python: - install: - - requirements: docs/requirements.txt \ No newline at end of file + install: + - method: pip + path: . + extra_requirements: [docs] \ No newline at end of file