chore(version): sync version directly from package.json in __init__.py and update version.py documentation

This commit is contained in:
Ivan
2026-04-24 18:10:40 -05:00
parent 782372ea92
commit 8f37bef3ed
3 changed files with 10 additions and 15 deletions
+2 -12
View File
@@ -2,15 +2,5 @@
"""Reticulum MeshChatX - A mesh network communications app."""
import re
from pathlib import Path
_vpath = Path(__file__).resolve().parent / "src" / "version.py"
_m = re.search(
r'^__version__\s*=\s*["\']([^"\']+)["\']',
_vpath.read_text(encoding="utf-8"),
re.MULTILINE,
)
if not _m:
raise RuntimeError("meshchatx/src/version.py: missing __version__ line")
__version__ = _m.group(1)
# Synced from package.json via scripts/sync_version.js (also writes meshchatx/src/version.py).
__version__ = "4.6.0"
+3 -1
View File
@@ -1,3 +1,5 @@
"""Version string synced from package.json. Do not edit by hand; run pnpm run version:sync."""
"""Version string synced from package.json. Do not edit by hand.
Run: pnpm run version:sync
"""
__version__ = "4.6.0"
+5 -2
View File
@@ -2,12 +2,13 @@
* Single source of truth: set "version" in package.json, then run:
* pnpm run version:sync
*
* Writes: meshchatx/src/version.py, pyproject.toml [project].version,
* Writes: meshchatx/__init__.py (__version__), meshchatx/src/version.py, pyproject.toml [project].version,
* meshchatx/src/backend/data/THIRD_PARTY_NOTICES.txt (reticulum-meshchatx line only),
* README + lang README "current version" lines, docs/meshchatx_on_raspberry_pi.md
* pipx example, packaging/arch/PKGBUILD pkgver / printf fallback.
*
* meshchatx/__init__.py reads __version__ from src/version.py without importing meshchatx.src.
* __version__ lives in meshchatx/__init__.py so Chaquopy/Android (which may not ship loose .py
* data files next to bytecode) always has a resolvable version. src/version.py stays for packaging and tools.
* The build script runs version:sync automatically.
*/
@@ -39,6 +40,8 @@ __version__ = "${version}"
`;
writeIfChanged(path.join(root, "meshchatx", "src", "version.py"), versionPy);
patchFile("meshchatx/__init__.py", (c) => c.replace(/^__version__\s*=\s*"[^"]*"\s*$/m, `__version__ = "${version}"`));
const pyprojectPath = path.join(root, "pyproject.toml");
let pyproject = fs.readFileSync(pyprojectPath, "utf8");
const pyprojectNext = pyproject.replace(/^version = "[^"]+"/m, `version = "${version}"`);