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:
parent
6a172296d4
commit
e44316c5b9
@ -2,7 +2,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import tomllib
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
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
|
# Utility function to fetch metadata from pyproject.toml
|
||||||
def get_project_metadata():
|
def get_project_metadata():
|
||||||
|
from pathlib import Path
|
||||||
|
import tomllib
|
||||||
|
|
||||||
# Dynamically resolve the correct path to pyproject.toml
|
# Dynamically resolve the correct path to pyproject.toml
|
||||||
root_dir = (
|
root_dir = (
|
||||||
Path(__file__).resolve().parent.parent.parent
|
Path(__file__).resolve().parent.parent.parent
|
||||||
) # Adjust path to project root
|
) # Adjust path to project root
|
||||||
pyproject_path = root_dir / "pyproject.toml"
|
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():
|
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:
|
with open(pyproject_path, "rb") as f:
|
||||||
pyproject = tomllib.load(f)
|
pyproject = tomllib.load(f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user