Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@
)
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))


def get_version_from_toml():
"""
Returns the version from the pyproject.toml file.
Supports PEP 621 formats. Works with Python 3.10+.
"""
path = os.path.join(os.path.dirname(__file__), '..', 'pyproject.toml')
version = "2.0.0"
try:
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

with open(path, "rb") as f:
data = tomllib.load(f)
return str(data.get("project", {}).get("version", version))
except Exception as e:
pass
return version

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down Expand Up @@ -78,7 +99,7 @@
# The short X.Y version.
version = '1.8'
# The full version, including alpha/beta/rc tags.
release = '1.8.1'
release = get_version_from_toml()

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down