Sync project metadata with pyproject.toml

Updated scripts and backend to dynamically retrieve project name and version from `pyproject.toml`. This ensures consistent metadata across the OpenAPI client generation and the FastAPI application.
This commit is contained in:
GotthardG 2024-12-17 10:28:36 +01:00
parent 5dff380c65
commit e4b2a15126
2 changed files with 9 additions and 1 deletions

View File

@ -26,7 +26,15 @@ from app.database import Base, engine, SessionLocal, load_sample_data
# Utility function to fetch metadata from pyproject.toml
def get_project_metadata():
with open("pyproject.toml", "rb") as f:
# Dynamically resolve the correct path to pyproject.toml
current_dir = Path(__file__).resolve().parent
root_dir = current_dir.parent.parent # Adjust based on structure
pyproject_path = root_dir / "pyproject.toml"
if not pyproject_path.exists():
raise FileNotFoundError(f"pyproject.toml not found at {pyproject_path}")
with open(pyproject_path, "rb") as f:
pyproject = tomllib.load(f)
name = pyproject["project"]["name"]
version = pyproject["project"]["version"]