branchy
Live, hierarchical console process trees for Python, with zero dependencies.
Visual sample
A successful run collapses to a calm, depth-styled tree:
✓ Deploy
✓ Validate
✓ Build
✓ Compile
✓ Link
A failed run keeps the transient logs visible:
✗ Publish
starting upload
✗ Sign package
private key not found
Installation
pip install branchy
Quick start
from branchy import process
import time
with process("Build") as build:
with build.child("Compile") as c:
c.log("gcc main.c")
time.sleep(0.5)
with build.child("Link") as l:
l.log("ld -o app")
time.sleep(0.3)
API usage
process(label) starts a root context. Inside the body:
p.log(message)appends transient output under the current node.p.child(label)creates a nested process.p.rename(new_label)retitles the running node — works on the root and on every child.show_elapsed=True(onprocessorchild, off by default) shows that node's elapsed time: whole seconds while running, frozen at one-decimal precision once the node is done or failed.- Clean exit marks the node done and clears its transient logs.
- Exception exit marks the node failed, keeps the logs, appends the exception message, and re-raises the exception.
Both process and child are context managers.
Output lifecycle
Logs are temporary detail. They disappear once a branch succeeds, but remain visible on failure so the reason can be seen.
During a running branch:
⠋ Build
compiling…
⠙ Compile
gcc main.c
After success:
✓ Build
✓ Compile
After failure:
✗ Build
compiling…
✗ Compile
gcc main.c
error: implicit declaration
A mid-run rename swaps the title in place, with no flash or recolor:
⠋ Compiling deps…
The next frame simply carries the new name:
⠙ Building wheels…
The rename shows in the live view and in the final output. Renaming a finished node is a no-op — finalized rows are immutable — and a longer label re-truncates with ... at the terminal width.
Elapsed time
Pass show_elapsed=True to process or child to time that one node — the flag is per node, off by default, and never inherited from the parent. While the node runs, the suffix ticks in whole seconds; when it completes or fails, the duration freezes at one-decimal precision (minute form from 60 s):
from branchy import process
import time
with process("Build", show_elapsed=True) as build:
with build.child("Compile") as c: # untimed node
time.sleep(0.4)
with build.child("Link", show_elapsed=True) as l:
time.sleep(1.1)
While a timed node runs:
⠙ Build (3s)
⠋ Compile
gcc main.c
After failure, the frozen duration stays visible in the final tree:
✗ Publish (4.1s)
starting upload
✗ Sign package
private key not found
On a non-TTY (CI) there are no live frames; the timer appears once, frozen, in the static output:
✓ Build (3.2s)
✓ Compile
✓ Link (1.1s)
Environment / behavior
| Variable / condition | Effect |
|---|---|
NO_COLOR set |
No color styling; cursor movement still works in a TTY. |
TERM=dumb |
Plain ASCII output, no ANSI cursor control. |
| stdout not a TTY | Static output; no animation; transient logs are not erased. |
COLUMNS |
Fallback terminal width when it cannot be queried from the OS. |
Examples
Nested success tree
from branchy import process
import time
with process("Deploy") as deploy:
with deploy.child("Validate") as v:
v.log("schema ok")
time.sleep(0.2)
with deploy.child("Build") as b:
with b.child("Compile") as c:
c.log("gcc -O2 main.c")
time.sleep(0.3)
with b.child("Link") as l:
l.log("ld -o app")
time.sleep(0.3)
Failure handling
from branchy import process
try:
with process("Publish") as p:
p.log("starting upload")
with p.child("Sign package") as s:
s.log("private key not found")
raise RuntimeError("signing failed")
except RuntimeError as exc:
print(f"Expected failure captured: {exc}")
Limitations
- Designed for small trees; rendering is
O(number of live rows)per frame. - Wide-character widths are best-effort via Unicode East Asian Width and combining-mark handling.
- With
show_elapsed=Trueon a very narrow terminal the label budget can reach zero, leaving only the glyph and the timer suffix. - Elapsed minute form (
(XmYYs)) grows unboundedly for runtimes of an hour or more; a right-aligned timer column is a possible future enhancement. - The library intentionally does not persist logs, show progress percentages, or provide pluggable themes.
Metadata
Release files for branchy 1.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| branchy-1.1.7.tar.gz | 11.2 kB | Without provenance | Details for branchy-1.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| branchy-1.1.7-py3-none-any.whl | Python 3 | none | any | Details for branchy-1.1.7-py3-none-any.whl |
Total release size: 21.9 kB
Release files / branchy-1.1.7.tar.gz
| Download URL | branchy-1.1.7.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7dcb0ad713fa19eb42e2fc9b0dd3010483d57bef7d3e91d2cbeb3a10840e917
|
|
BLAKE2b-256 checksum How to use checksums |
65016826e55dc012b059c7a8085889145f4e4ff95fedf70b37c53404a0712ffe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / branchy-1.1.7-py3-none-any.whl
| Download URL | branchy-1.1.7-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8c5a307b651ae94c496967d71a569cde9a90f107255e8bacf419fc50dd9a0b7
|
|
BLAKE2b-256 checksum How to use checksums |
9e994a26ffbf2c01f75480cd2178205bf598b670b0a020d4fc0a0a52be3f4fbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for branchy 1.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.