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 diff --git a/docs/source/conf.py b/docs/source/conf.py index cf5ac8c..bb49b87 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,13 +8,19 @@ import os import sys +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')) -import importlib.metadata project = 'CPax' copyright = '2025, Jan Lukas Späh' author = 'Jan Lukas Späh' -release = importlib.metadata.version("cpax") +release = __version__ version = ".".join(release.split(".")[:2]) # -- General configuration ---------------------------------------------------