Skip to main content

bough is a tool to determine which uv workspace packages need rebuilding based on git changes

Project description

Bough

bough is a tool to determine which uv workspace packages need rebuilding 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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bough-0.1.3.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bough-0.1.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file bough-0.1.3.tar.gz.

File metadata

  • Download URL: bough-0.1.3.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for bough-0.1.3.tar.gz
Algorithm Hash digest
SHA256 78eb050e194881bb54acd7557bb024140dfce9d595ca2802091a3938ced334b8
MD5 9a2dc02a4646b25f8d4dc815903528c0
BLAKE2b-256 3d4ebbaf873e1bc478ccb07f000be4d144d91dc60ed90dfb6417f8bd0c105fa7

See more details on using hashes here.

File details

Details for the file bough-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: bough-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for bough-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 29c5fe8efa5e75724feb5709ab67541dedd00b97c726fe6727c53daa2dab396b
MD5 bfb2f329803f50326b5e45b594f3d63d
BLAKE2b-256 30e6780ca8f028e520c502af377e42791e0015f83eafd714a946630f81c13aa9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page