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 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
- Find all workspace members from
pyproject.toml - Build dependency graph from
tool.uv.sources - Detect changed files with git diff
- Apply change detection rules:
- File changed inside package → package directly affected
- File changed at workspace root → all packages affected
- Calculate transitive impacts (if A depends on B and B changes, A is affected)
- Filter to only buildable packages
- Output build list
If packages/database/models.py changes:
databaseis directly affectedsharedis affected (depends on database)apiis affected (depends on database and shared)webis affected (depends on shared)- Output shows only
apiandweb(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
- una - Unify Python packaging commands
- postmodern-mono - Python monorepo example
- Nx affected - Similar concept for JS/TS monorepos
- Turborepo --affected - Git-based filtering for builds
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bough-0.3.2.tar.gz.
File metadata
- Download URL: bough-0.3.2.tar.gz
- Upload date:
- Size: 40.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.1 {"installer":{"name":"uv","version":"0.10.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f68f064a585eae7e7087e1e69698761da841e4a27d6b3debd3a025fc2c0c4543
|
|
| MD5 |
fe63bc770fb4a4a6a722ebdef7f689b9
|
|
| BLAKE2b-256 |
925911cd6af039ce779ca150a687973a84cccbe76d3a812b981d46effedfc7f7
|
File details
Details for the file bough-0.3.2-py3-none-any.whl.
File metadata
- Download URL: bough-0.3.2-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.1 {"installer":{"name":"uv","version":"0.10.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f2f370bcb85b99c1b82b4865696efa03df827d9eecefd8318f006db4035f16
|
|
| MD5 |
4aaac7f73c97f081eacd803cc2d041f0
|
|
| BLAKE2b-256 |
a2cdd6312803a22e47f11272ce4cdf904552c1c527aa30fc47dd654bad93fc58
|