From e4b2a15126e485467f401492e0254954a333025c Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:28:36 +0100 Subject: [PATCH] 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. --- backend/main.py | 10 +++++++++- backend/pyproject.toml => pyproject.toml | 0 2 files changed, 9 insertions(+), 1 deletion(-) rename backend/pyproject.toml => pyproject.toml (100%) diff --git a/backend/main.py b/backend/main.py index 243c7b3..8235563 100644 --- a/backend/main.py +++ b/backend/main.py @@ -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"] diff --git a/backend/pyproject.toml b/pyproject.toml similarity index 100% rename from backend/pyproject.toml rename to pyproject.toml