Files
periscope/backend/_version.py
micheleandCursor 8d2b85600f Rebrand Pinscope to Periscope across product and codebase.
Rename the core package to periscopex, update UI/docs/Docker/deploy defaults to periscope.michelebigi.it, and keep legacy version/storage key aliases so existing projects keep working.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 20:02:04 +02:00

39 lines
999 B
Python

"""Periscope app version, sourced from frontend/content/changelog.md.
The changelog is the single source of truth for the user-facing version.
The Dockerfile copies it into the image at /app/changelog.md; locally we
fall back to the in-repo path.
"""
from __future__ import annotations
import re
from functools import lru_cache
from pathlib import Path
def _candidate_paths() -> list[Path]:
here = Path(__file__).resolve()
return [
Path("/app/changelog.md"),
here.parent.parent / "frontend" / "content" / "changelog.md",
]
_VERSION_RE = re.compile(r"^##\s+(\d+\.\d+\.\d+)\b", re.MULTILINE)
@lru_cache(maxsize=1)
def get_periscope_version() -> str:
for path in _candidate_paths():
try:
text = path.read_text(encoding="utf-8")
except (FileNotFoundError, OSError):
continue
m = _VERSION_RE.search(text)
if m:
return m.group(1)
return "unknown"
PERISCOPE_VERSION = get_periscope_version()