setup
setup
¶
Check and certify package-owned setup without knowing the dependency graph.
__all__ = ['SetupStatus', 'SetupCheck', 'SetupReceipt', 'SetupRequiredError', 'SetupDowngradeError', 'setup_status', 'setup_lock', 'require_no_downgrade', 'require_setup', 'python_identity']
module-attribute
¶
SetupCheck(owner, component, status, diagnostic='')
dataclass
¶
SetupReceipt(path, owner, version, inputs)
dataclass
¶
Certify one owner's version and setup inputs in an atomic JSON receipt.
Owners preflight their full dependency closure before changing artifacts,
clear their receipt immediately before their own writes, and write it only
after verification succeeds, holding setup_lock
across the whole transition. A receipt never certifies child packages.
path
instance-attribute
¶
owner
instance-attribute
¶
version
instance-attribute
¶
inputs
instance-attribute
¶
check()
¶
Compare the receipt with the current owner, version, and setup inputs.
Source code in src/terok_util/setup.py
clear()
¶
write()
¶
Atomically certify successful setup, refusing an unsupported downgrade.
Source code in src/terok_util/setup.py
SetupRequiredError
¶
Bases: RuntimeError
Setup must complete before an operation may change running tasks.
SetupDowngradeError
¶
Bases: SetupRequiredError
Newer installed setup cannot be replaced by an older package.
setup_lock(*, allow_downgrade=False)
¶
Serialize setup mutations across packages, processes, and threads.
Hold this around preflight, artifact changes, and receipt writes. Nested
calls in the owning thread share the lock; competing callers fail with
SetupRequiredError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allow_downgrade
|
bool
|
Authorize setup to replace newer receipts in this scope. Nested setup calls inherit permission. Readiness checks still reject unrepaired setup; state compatibility is not guaranteed. |
False
|
Source code in src/terok_util/setup.py
setup_status(checks)
¶
Summarize checks, prioritizing unsupported downgrades over repairable setup.
Source code in src/terok_util/setup.py
require_no_downgrade(checks)
¶
Reject newer setup unless the current setup scope explicitly permits it.
require_setup(checks)
¶
Require all checks to be ready, using typed errors instead of process exits.
An owner whose receipt is missing has no setup at all — never run, or cleared by a run that did not complete — so its other components can say nothing a first-time user acts on. Such an owner is reported as that one fact, and the hint asks to run setup, not to run it again.
Source code in src/terok_util/setup.py
python_identity()
¶
Identify the running bootstrap Python and detect replacement or disappearance.