From e44316c5b9a8a5d97228128422c82ee6d95422ef Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:40:39 +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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index 990e1ad..f3f76db 100644 --- a/backend/main.py +++ b/backend/main.py @@ -2,7 +2,6 @@ import sys import os import json -import tomllib from pathlib import Path from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware @@ -26,14 +25,20 @@ from app.database import Base, engine, SessionLocal, load_sample_data # Utility function to fetch metadata from pyproject.toml def get_project_metadata(): + from pathlib import Path + import tomllib + # Dynamically resolve the correct path to pyproject.toml root_dir = ( Path(__file__).resolve().parent.parent.parent ) # Adjust path to project root pyproject_path = root_dir / "pyproject.toml" + # Print the resolved path for debugging + print(f"Looking for pyproject.toml at: {pyproject_path}") + if not pyproject_path.exists(): - raise FileNotFoundError(f"pyproject.toml not found at {pyproject_path}") + raise FileNotFoundError(f"{pyproject_path} not found") with open(pyproject_path, "rb") as f: pyproject = tomllib.load(f)