"""Version applicative unique exposee par l'application et l'image Docker."""

import os
from pathlib import Path


def get_version() -> str:
    configured = os.environ.get("GMAO_VERSION", "").strip()
    if configured:
        return configured

    version_file = Path(__file__).resolve().parents[1] / "VERSION"
    try:
        return version_file.read_text(encoding="utf-8").strip()
    except OSError:
        return "unknown"


__version__ = get_version()
