package.json (single source of truth) + the three toolchain mirrors to 0.3.20; Cargo.lock + uv.lock regenerated (version lines only). CHANGELOG [Unreleased] renamed to [0.3.20] — 2026-07-12 with the release headline, sections merged into house style (one Added, one Fixed). Ships the #1101 stale-"ready" race fix (0.3.19 users are hitting it today), the in-app uninstaller (#1099), and the Linux/Windows backend-log-dir fix. test_app_version.py lockstep: 6 passed. bun install --frozen-lockfile: clean. Co-authored-by: mergetest <nizam4103@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
"""Single source of truth for the app version at runtime.
|
|
|
|
Read from the installed package metadata (driven by ``pyproject.toml``) so the
|
|
FastAPI/API version and exported-bundle metadata never drift to a stale literal
|
|
— the prior "0.4.0" / "0.2.7" bug, and the v0.3.6 desktop build that reported
|
|
"0.3.5" because the *frozen* backend couldn't read its own metadata.
|
|
|
|
Resolution order:
|
|
1. installed package metadata — correct in any ``uv sync``'d env and, thanks
|
|
to ``copy_metadata('omnivoice')`` in ``backend.spec``, in the frozen build;
|
|
2. ``pyproject.toml`` walked up from this file — correct for a raw source
|
|
checkout that was never installed;
|
|
3. ``_FALLBACK_VERSION`` — a last resort, kept in lockstep with the four
|
|
version files by ``tests/test_app_version.py`` so it can never silently
|
|
drift again.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from importlib.metadata import PackageNotFoundError, version
|
|
from pathlib import Path
|
|
|
|
# Last-resort literal. Guarded by
|
|
# tests/test_app_version.py::test_all_version_files_in_lockstep and bumped by
|
|
# release.yml's version-bump job, so it stays equal to
|
|
# pyproject/tauri.conf/Cargo/package.json.
|
|
_FALLBACK_VERSION = "0.3.20"
|
|
|
|
|
|
def _fallback_version() -> str:
|
|
"""Version for contexts where package metadata is unavailable."""
|
|
for parent in Path(__file__).resolve().parents:
|
|
pyproject = parent / "pyproject.toml"
|
|
if pyproject.is_file():
|
|
match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', pyproject.read_text())
|
|
if match:
|
|
return match.group(1)
|
|
return _FALLBACK_VERSION
|
|
|
|
|
|
try:
|
|
APP_VERSION = version("omnivoice")
|
|
except PackageNotFoundError: # frozen build w/o metadata, or non-installed checkout
|
|
APP_VERSION = _fallback_version()
|