| 13 | |
| 14 | # Where code lives (PROJECT_ROOT) and where runtime state belongs are the same |
| 15 | # directory in a source checkout but not in an installed wheel, where |
| 16 | # PROJECT_ROOT is site-packages. Writing data there loses it on upgrade. |
| 17 | try: |
| 18 | from paperflow.runtime import data_dir as _resolve_data_dir |
| 19 | from paperflow.runtime import paperflow_home as _resolve_home |
| 20 | |
| 21 | RUNTIME_ROOT = _resolve_home() |
| 22 | DATA_DIR = _resolve_data_dir() |
| 23 | except Exception: |
| 24 | RUNTIME_ROOT = PROJECT_ROOT |
| 25 | DATA_DIR = PROJECT_ROOT / "data" |
| 26 | |
| 27 | |
| 28 | def ensure_runtime_dirs() -> None: |
| 29 | for relative in ( |
| 30 | "db_backups", |
| 31 | "embeddings_cache", |
| 32 | "papers", |
| 33 | "reading_reports", |