음성 재생과 운영 배포 정리
This commit is contained in:
parent
8ed185ce6c
commit
ac7db95542
1020 changed files with 46863 additions and 2175 deletions
40
apps/api/app/paths.py
Normal file
40
apps/api/app/paths.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"""Filesystem path helpers for source-checkout and container runtimes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def repo_root() -> Path:
|
||||
"""Return the Vignette repository root.
|
||||
|
||||
The API is run both from a source checkout and from Docker, where the code
|
||||
lives under /app/apps/api. Keep that layout knowledge here instead of
|
||||
repeating fragile ``Path(__file__).parents[...]`` offsets across modules.
|
||||
"""
|
||||
override = os.getenv("VIGNETTE_REPO_ROOT", "").strip()
|
||||
if override:
|
||||
return Path(override).expanduser().resolve()
|
||||
|
||||
current = Path(__file__).resolve()
|
||||
for candidate in current.parents:
|
||||
if (
|
||||
(candidate / "apps" / "api" / "app").is_dir()
|
||||
and (candidate / "data").exists()
|
||||
):
|
||||
return candidate
|
||||
for candidate in current.parents:
|
||||
if (
|
||||
(candidate / "apps" / "api").is_dir()
|
||||
and (candidate / "README.md").exists()
|
||||
):
|
||||
return candidate
|
||||
raise RuntimeError("Vignette repository root not found; set VIGNETTE_REPO_ROOT")
|
||||
|
||||
|
||||
def repo_path(*parts: str) -> Path:
|
||||
"""Build an absolute path under the repository root."""
|
||||
return repo_root().joinpath(*parts)
|
||||
Loading…
Add table
Add a link
Reference in a new issue