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

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.4
File Size Uploaded Provenance Actions
bough-0.3.4.tar.gz 41.9 kB Without provenance Details for bough-0.3.4.tar.gz

Built distribution (wheel)

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

Total release size: 52.0 kB

Release files / bough-0.3.4.tar.gz

Download URL bough-0.3.4.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ee459357a444a635b728ab410330d925d1625781f60881686e9779906ddc42bb
BLAKE2b-256 checksum
How to use checksums
2a05c58ce61bbbf8697104fe49f87ce4a923c5e67f9fd0b03d4cb0a13104e352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4-py3-none-any.whl

Download URL bough-0.3.4-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fa65ebd23521d465b547a729f6d81a46827eb72b93c78b4e3af0f744550e5b2
BLAKE2b-256 checksum
How to use checksums
97baa99287cbd6c7d1acbf88f814b0dca20f655cea333a57190bd549f93751ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4

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