rsbuild
A self-sufficient runtime to build projects.
What is rsbuild?
rsbuild is a unified command-line tool that streamlines the build process for polyglot projects. It eliminates the need to remember different build commands for different ecosystems by providing a consistent interface for:
- Python wheels - Build distributable packages using
uv - Docker containers - Build and manage Docker Compose services
- Rust binaries - Compile Rust projects with cargo
- Cython modules - Compile
.pyxfiles and package them into wheels - Project scaffolding - Initialize new Python projects with best practices
Why rsbuild?
Modern projects often combine multiple technologies. A typical project might have:
- Python code for the application logic
- Cython for performance-critical components
- Docker for deployment
- Rust for CLI tools or native extensions
Without rsbuild, you'd need to remember:
With rsbuild, it's simply:
Key Features
| Feature | Description |
|---|---|
| Unified Interface | One command for all build tasks |
| Watch Mode | Automatically rebuild on file changes |
| Parallel Execution | Build multiple targets simultaneously |
| JSON Output | Machine-readable output for CI/CD integration |
| Progress Indicators | Visual feedback during long operations |
| Dry Run | Preview commands without executing them |
| Project Scaffolding | Initialize Python projects with modern best practices |
Installation
From crates.io
From source
Verify installation
This checks that all required and optional tools are available on your system.
Quick Start
# Initialize a new Python project
# Build everything
# Watch for changes and rebuild
# Check system dependencies
Usage
Global Options
| Option | Description |
|---|---|
-v, --verbose |
Increase output verbosity |
-q, --quiet |
Suppress non-essential output |
--dry-run |
Preview commands without executing them |
-y, --yes |
Skip confirmation prompts |
--json |
Output results in JSON format (implies --quiet) |
-j, --jobs <N> |
Number of parallel jobs (default: 1) |
-h, --help |
Print help information |
-V, --version |
Print version |
Commands Overview
| Command | Description |
|---|---|
build |
Build artifacts (wheel, docker, cargo) |
pull |
Pull Docker images |
run |
Run Docker Compose services |
clean |
Clean build artifacts and caches |
cython |
Compile Cython modules and package into wheel |
python |
Python project management |
watch |
Watch files and rebuild on changes |
glances |
Run glances system monitor |
completions |
Generate shell completion scripts |
doctor |
Check if required tools are installed |
Build Commands
The build command is the core of rsbuild, providing a unified interface for building different types of artifacts.
Build Python Wheel
This command:
- Creates a
dist/legacydirectory and moves existing wheels there - Builds a new wheel using
uv build --wheel - Cleans up build artifacts
- Places the wheel in
dist/
Requirements: uv must be installed.
Build Rust Binary
# Release build (default, optimized)
# Debug build (faster compilation)
The binary is placed in target/<OS>/<ARCH>/release/ or target/<OS>/<ARCH>/debug/.
Requirements: cargo must be installed.
Build Docker Service
# Build a specific service
# Build without cache
This wraps docker compose build with consistent output formatting.
Requirements: docker must be installed.
Build All Targets
# Build everything sequentially
# Build in parallel (4 jobs)
# Get JSON output
This builds:
- Python wheel (if
uvis available) - Docker services
vanillaandsandbox(ifdocker-compose.ymlexists)
When using -j for parallel execution, builds run concurrently with a progress bar showing completion status.
Watch Mode
Watch mode monitors your files and automatically triggers rebuilds when changes are detected.
# Watch Python files and rebuild wheel
# Watch Rust files and rebuild binary
# Watch Dockerfile and rebuild container
# Watch Cython files and recompile
Watch Options
| Option | Description |
|---|---|
-d, --debounce <MS> |
Debounce delay in milliseconds (default: 500) |
-p, --path <PATH> |
Additional paths to watch (can be repeated) |
File Patterns
Each watch target monitors specific file patterns:
| Target | Patterns |
|---|---|
wheel |
*.py, pyproject.toml, setup.py, setup.cfg |
cargo |
*.rs, Cargo.toml, Cargo.lock |
docker |
Dockerfile, docker-compose.yml, compose.yml, *.dockerfile |
cython |
*.pyx, *.pxd, *.pxi |
Example
# Watch with custom debounce and additional paths
# Press Ctrl+C to stop watching
Parallel Execution
Many commands support parallel execution using the -j flag:
# Build all targets with 4 parallel jobs
# Pull all images in parallel
Parallel execution:
- Uses a thread pool sized to the specified job count
- Shows a progress bar with completion status
- Collects all results (doesn't fail fast)
- Falls back to sequential execution when
-j1
JSON Output
The --json flag outputs machine-readable JSON, useful for CI/CD pipelines and scripting:
# Check system status as JSON
|
# Build and capture results
Doctor JSON Output
Build JSON Output
Pull Commands
Pull Docker images defined in your compose file:
# Pull all configured images
# Pull in parallel
# Pull a specific service image
Run Docker Services
Run Docker Compose services with a simplified interface:
# Run a service
# Run with additional arguments
Cython Compilation
Compile Cython modules and package them into distributable wheels:
This command:
- Validates the package directory exists
- Creates a temporary build directory
- Compiles
.pyxfiles to.soshared objects usingcythonize - Cleans up intermediate
.cfiles - Packages the compiled modules into a wheel
- Moves the wheel to
dist/
Requirements: cythonize, rsync, and pip must be installed.
Python Project Management
Initialize a New Project
# Initialize in current directory
# Specify a custom package name
# Skip optional components
# Preview what would be created
This creates a complete Python project structure:
mypackage/
├── pyproject.toml # Modern Python packaging (hatchling)
├── README.md # Project documentation
├── .pre-commit-config.yaml # Pre-commit hooks (ruff, mypy)
├── .gitignore # Python-specific ignores
├── Taskfile.yml # Task runner commands
├── Dockerfile # Container definition
├── docker-compose.yml # Container orchestration
├── mypackage/
│ ├── __init__.py # Package with __version__
│ └── tests/
│ └── test_example.py # Sample test
└── .devcontainer/
└── devcontainer.json # VS Code dev container
Sync Version
Keep your package's __version__ in sync with pyproject.toml:
This reads the version from pyproject.toml and updates __version__ and __build__ in your package's __init__.py.
Generated Taskfile Commands
After initialization, use the task runner:
Clean
Remove build artifacts and caches:
# Clean Python artifacts (egg-info, pycache, notebooks)
# Also remove Rust target directory
Doctor
Diagnose your system for required and optional tools:
# Human-readable output
# Machine-readable JSON
Required Tools
| Tool | Purpose |
|---|---|
cargo |
Rust builds |
docker |
Docker builds |
Optional Tools
| Tool | Purpose |
|---|---|
uv |
Python package management & wheel builds |
task |
Task runner (Taskfile) |
pip |
Python package installer (legacy) |
cythonize |
Cython compilation |
rsync |
Cython packaging |
glances |
System monitoring |
pre-commit |
Git hooks |
Shell Completions
Generate shell completions for tab completion:
# Bash
# Zsh
# Fish
# PowerShell
Project Structure
src/
├── main.rs # Entry point and command dispatch
├── cli.rs # CLI definitions (clap derive)
├── error.rs # Error types (thiserror)
├── executor.rs # Command execution with progress support
├── output.rs # JSON output formatting
├── progress.rs # Progress bar utilities (indicatif)
├── parallel.rs # Parallel execution (rayon)
├── watch.rs # File watching (notify)
└── commands/
├── mod.rs # Module exports
├── build.rs # Build commands (wheel, cargo, docker)
├── clean.rs # Clean command
├── cython.rs # Cython compilation workflow
├── doctor.rs # System diagnostics
├── pull.rs # Docker pull commands
├── python.rs # Python project scaffolding
└── run.rs # Docker run command
Examples
CI/CD Integration
# GitHub Actions example
- name: Check dependencies
run: rsbuild doctor --json | jq -e '.all_required_installed'
- name: Build all artifacts
run: rsbuild build all -j4 --json > build-report.json
- name: Upload build report
uses: actions/upload-artifact@v3
with:
name: build-report
path: build-report.json
Development Workflow
# Terminal 1: Watch and rebuild on changes
# Terminal 2: Run tests after each rebuild
Building a Release
# Ensure clean state
# Build everything in parallel
# Verify the builds
License
MIT