Skip to main content

Bough

bough is a tool to determine which uv workspace packages need building or testing based on git changes.

Problem

When using uv workspaces, it's often unclear which packages are affected by a given change. This leads to either rebuilding everything (wasteful) or missing necessary rebuilds (broken deployments).

Solution

Analyze dependencies and git diffs to identify affected packages, then build only what's needed.

Usage

bough

# Custom base commit
bough --base main analyze

# Display dependency graph
bough graph

# Output GitHub Actions matrix format
bough --format github-matrix analyze

Examples

my-app/
├── pyproject.toml
├── packages/
│   ├── auth/          # library (no deps)
│   ├── database/      # library (no deps)
│   └── shared/        # library (depends on: database)
└── apps/
    ├── api/           # buildable (depends on: auth, database, shared)
    └── web/           # buildable (depends on: shared)

Graph

The bough graph command shows the dependency relationships between packages:

🚀 Buildable Packages:
==================================================
📦 api (apps/api)
   └─ depends on: auth, database, shared

📦 web (apps/web)
   └─ depends on: shared

📚 Library Packages:
==================================================
📖 auth (packages/auth)
   ├─ depends on: (none)
   └─ depended on by: api

📖 database (packages/database)
   ├─ depends on: (none)
   └─ depended on by: api, shared, web

📖 shared (packages/shared)
   ├─ depends on: database
   └─ depended on by: api, web

Analyze

The bough analyze command shows what packages should be built based on what files have changed.

GitHub Matrix (for parallel CI jobs):

{
  "include": [
    {"package": "api", "directory": "apps/api"},
    {"package": "web", "directory": "apps/web"}
  ]
}

Text (default):

Packages to rebuild:
  api (apps/api)
  web (apps/web)

Changed files:
  packages/database/models.py

Configuration

.bough.yml:

# Packages that produce build artifacts (default: ["apps/*"])
buildable:
  - "apps/*"

# Files that never trigger rebuilds
ignore:
  - "*.md"
  - "docs/**"

GitHub Actions Integration

See GitHub Actions Integration Guide for examples of using Bough in CI/CD pipelines.

How It Works

  1. Find all workspace members from pyproject.toml
  2. Build dependency graph from tool.uv.sources
  3. Detect changed files with git diff
  4. Apply change detection rules:
    • File changed inside package → package directly affected
    • File changed at workspace root → all packages affected
  5. Calculate transitive impacts (if A depends on B and B changes, A is affected)
  6. Filter to only buildable packages
  7. Output build list

If packages/database/models.py changes:

  • database is directly affected
  • shared is affected (depends on database)
  • api is affected (depends on database and shared)
  • web is affected (depends on shared)
  • Output shows only api and web (they're buildable)

Non-Goals

This tool is intentionally simple:

  • Not a build system (like Bazel or Buck)
  • Not a task runner
  • Not multi-language aware
  • Not trying to optimize build order or parallelization
  • Not caching build artifacts

Prior Art

Roadmap

  • setup a release workflow to pypi
  • provide an option that outputs all affected packages, not just buildable ones (useful for selectively running tests)
  • handle working tree changes
  • add a contributing guide
  • check in a sample configuration file and document the defaults better
  • improve or remove the github actions examples

Metadata

Release files for bough 0.3.3

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

Source distribution (sdist)

Source distribution for bough 0.3.3
File Size Uploaded Provenance Actions
bough-0.3.3.tar.gz 41.9 kB Without provenance Details for bough-0.3.3.tar.gz

Built distribution (wheel)

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

Total release size: 52.0 kB

Release files / bough-0.3.3.tar.gz

Download URL bough-0.3.3.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
be0e993b6b5266922176d61b6b4e9f25dc1b3abb4469fb97508841e8435f9435
BLAKE2b-256 checksum
How to use checksums
f25637f91b778c7cb42a684f21c100d9b575cfe64410df5841ee1d11ebf49bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bough-0.3.3-py3-none-any.whl

Download URL bough-0.3.3-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d6b2de58bc85dbaf7804cfd3e6d7caff43d1cdcf8cfe886a282c6458e68d28e
BLAKE2b-256 checksum
How to use checksums
2c7241eca0e8def1e19e15dc397187e9904e424e55c6c7ed51bb03eda4157944
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for bough 0.3.3

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