diff --git a/meshchatx/__init__.py b/meshchatx/__init__.py index c35d74d..83bcf82 100644 --- a/meshchatx/__init__.py +++ b/meshchatx/__init__.py @@ -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" \ No newline at end of file diff --git a/meshchatx/src/version.py b/meshchatx/src/version.py index 0dc78c5..cadbe5f 100644 --- a/meshchatx/src/version.py +++ b/meshchatx/src/version.py @@ -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" diff --git a/scripts/sync_version.js b/scripts/sync_version.js index 5145d4f..02130a7 100644 --- a/scripts/sync_version.js +++ b/scripts/sync_version.js @@ -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}"`);