All seven v1 capabilities are landed (ROADMAP's v1 target is met), so this is the first release of the 1.x train. Staged as a beta rather than cut final on the operator's call: per the canonical policy `-beta.N` means feature-complete, external testing, no new features, focus is on bugs — which is exactly this state, with a cross-frontier bug-hunt panel outstanding on U7's diff. The repo learned this sequencing the hard way once: v0.2.0 was tagged and announced while a contract panel was in flight, the panel found three defects in the code just released, and v0.2.1 shipped within the hour. A beta is the designed answer to that, not a workaround for it. ALSO FIXES A SECOND COPY OF THE VERSION, found while cutting this one. `booth.__version__` was the literal `0.1.0` and had been wrong through six releases. It is now read from pyproject.toml — deliberately NOT from importlib.metadata, which describes a different artifact: this repo has no build step and no install step (booth.service runs uvicorn with WorkingDirectory set to the tree), and the venv was carrying a vestigial booth-0.3.0.dist-info with no package directory behind it. Installed metadata therefore reported 0.3.0 for a tree at 1.0.0b1 — confidently wrong and varying by environment, which is worse than a literal that at least fails the same way everywhere. booth/__init__.py is also, it turns out, effectively stdlib-only: scripts/booth imports booth.links / booth.marks / booth.manifest under the system python3 with no venv, and every one of those executes the package root first. Nothing asserted it. test_stdlib_only now covers __init__, and the no-venv import path is verified under python3.11 reporting 1.0.0b1. 642 tests green.
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
"""The Booth — ephemeral media drop board. See booth.app for the server.
|
|
|
|
⚠ THIS FILE IS EFFECTIVELY STDLIB-ONLY and nothing used to say so. `scripts/booth`
|
|
imports `booth.links` / `booth.marks` / `booth.manifest` under the SYSTEM python3
|
|
with no venv, and importing any of them executes this module first — so a single
|
|
third-party import here breaks `booth ask` on every fleet host exactly as one in
|
|
those three would. `test_stdlib_only` now covers `__init__` for that reason.
|
|
"""
|
|
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
_PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml"
|
|
|
|
|
|
def _declared_version() -> str:
|
|
"""The version of the code actually running, read from `pyproject.toml`.
|
|
|
|
⚠ NOT `importlib.metadata`, and the reason is this repo's own shape: there
|
|
is no build step and no install step — `booth.service` runs uvicorn with
|
|
WorkingDirectory set to the repo, so the running code IS this tree.
|
|
Installed metadata describes a DIFFERENT artifact and was found saying
|
|
`0.3.0` (a vestigial dist-info, three releases stale, with no package
|
|
directory behind it) while the tree was at `1.0.0b1`. A confidently wrong
|
|
number that varies by environment is worse than the hardcoded `0.1.0` this
|
|
replaced, which at least failed the same way everywhere.
|
|
|
|
Falls back to installed metadata for the case this repo does not have but a
|
|
consumer might: packaged as a wheel, where pyproject does not ship.
|
|
"""
|
|
try:
|
|
return tomllib.loads(_PYPROJECT.read_text())["project"]["version"]
|
|
except (OSError, KeyError, tomllib.TOMLDecodeError):
|
|
try:
|
|
from importlib.metadata import version
|
|
|
|
return version("booth")
|
|
except Exception:
|
|
return "0.0.0+unknown"
|
|
|
|
|
|
__version__ = _declared_version()
|