File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 11import os
22import sys
3+ from pathlib import Path
4+
5+ try :
6+ import tomllib # Python 3.11+
7+ except ImportError :
8+ import tomli as tomllib # pip install tomli for older Pythons
39
410# -- Path setup --------------------------------------------------------------
511# Ensure the project package is importable for autodoc (assumes src layout)
814# -- Project information -----------------------------------------------------
915project = "python-project-template-AS"
1016author = "Andrea Scaglioni"
11- # Keep in sync with pyproject.toml
12- release = "0.1.0"
17+
18+ # Read project version from pyproject.toml
19+ pyproject_path = Path (__file__ ).resolve ().parents [1 ] / "pyproject.toml"
20+ release = "0.0.0"
21+ if pyproject_path .exists ():
22+ with pyproject_path .open ("rb" ) as f :
23+ data = tomllib .load (f )
24+ # PEP 621
25+ release = (
26+ data .get ("project" , {}).get ("version" )
27+ or data .get ("tool" , {}).get ("poetry" , {}).get ("version" )
28+ or release
29+ )
1330
1431# -- General configuration ---------------------------------------------------
1532extensions = [
You can’t perform that action at this time.
0 commit comments