Skip to main content

branchy

Live, hierarchical console process trees for Python, with zero dependencies.

PyPI Python versions License: MIT

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.
  • 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

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.
  • The library intentionally does not persist logs, show progress percentages, or provide pluggable themes.

Metadata

Release files for branchy 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for branchy 1.1.0
File Size Uploaded Provenance Actions
branchy-1.1.0.tar.gz 6.6 kB Without provenance Details for branchy-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for branchy 1.1.0
File Interpreter ABI Platform Actions
branchy-1.1.0-py3-none-any.whl Python 3 none any Details for branchy-1.1.0-py3-none-any.whl

Total release size: 14.6 kB

Release files / branchy-1.1.0.tar.gz

Download URL branchy-1.1.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
22efa08722c3d4a10e78d859da910dc71c6db4b60023d25e7e8a643a37819548
BLAKE2b-256 checksum
How to use checksums
8d22f73e55cbce9ee682a0a534fb8f77f69d02cd9e2738601f538b22801d429f
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.0-py3-none-any.whl

Download URL branchy-1.1.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5d9b4da125ec86874a0c7d7379742b996f673e4d5a870ee273e4219de114b68
BLAKE2b-256 checksum
How to use checksums
2e539690f11115dde8d30507982d0490ee2141692fe8f665a43b337f4a77f1e2
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.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page