rattler - Rust Conda Package Management Library Cheatsheet
rattler is a set of Rust libraries and tools for working with the conda packaging ecosystem, built by prefix.dev. It reimplements conda’s core operations — parsing repodata, resolving dependencies, downloading and installing packages — with a fast solver (resolvo) and no Python dependency. It is the engine underneath pixi, and its companion rattler-build is a modern replacement for conda-build that constructs packages from a declarative recipe.
Components
| Component | Purpose |
|---|
rattler (crates) | Libraries: repodata, solver, installer |
rattler-build | Build conda packages from recipes |
rattler-index | Generate channel repodata |
| resolvo | The SAT dependency solver |
Installing rattler-build
| Method | Command |
|---|
| Cargo | cargo install rattler-build |
| pixi | pixi global install rattler-build |
| conda | conda install -c conda-forge rattler-build |
| Binary | download from GitHub Releases |
| Verify | rattler-build --version |
Building a Package
# recipe.yaml
package:
name: mypackage
version: 1.0.0
source:
url: https://example.com/mypackage-1.0.0.tar.gz
sha256: abc123...
build:
number: 0
script: python -m pip install . -vv
requirements:
host:
- python >=3.9
- pip
run:
- python >=3.9
- numpy
tests:
- python:
imports:
- mypackage
about:
homepage: https://example.com
license: MIT
summary: An example package
rattler-build build --recipe recipe.yaml
| Command | Description |
|---|
rattler-build build --recipe FILE | Build the package |
rattler-build build -r . --target-platform linux-64 | Cross-platform target |
rattler-build test --package-file X.conda | Run the recipe’s tests |
rattler-build upload | Publish to a channel |
--output-dir DIR | Where built artifacts land |
| Section | Purpose |
|---|
package | Name and version |
source | URL/git + checksum, or local path |
build | Build number, script, skip conditions |
requirements | build / host / run / run_constraints |
tests | Import, script, and package-content tests |
about | License, homepage, summary |
context | Variables reusable via Jinja |
context:
version: "1.0.0"
package:
name: mypackage
version: ${{ version }}
Variants (Build Matrices)
# variants.yaml — build against several Python versions
python:
- "3.11"
- "3.12"
rattler-build build --recipe recipe.yaml --variant-config variants.yaml
Using the Rust Libraries
// Conceptual: resolve and install an environment programmatically
use rattler_solve::{SolverImpl, SolverTask};
// 1) fetch repodata for the channels
// 2) build a SolverTask with your specs
// 3) solve → list of package records
// 4) install into a prefix with rattler's installer
| Crate | Provides |
|---|
rattler_repodata_gateway | Fetch/cache channel repodata |
rattler_solve | Dependency resolution (resolvo) |
rattler_installs_packages | Install into a prefix |
rattler_conda_types | Core types (MatchSpec, RepoData) |
rattler-build vs conda-build
| Aspect | rattler-build | conda-build |
|---|
| Language | Rust | Python |
| Speed | Much faster | Slower |
| Recipe format | v1 recipe.yaml | meta.yaml |
| Dependencies | Standalone binary | Requires conda/Python |
| Best for | New recipes, CI speed | Legacy recipes |
Where rattler Fits
| Tool | Relationship |
|---|
| pixi | Built on rattler |
| conda-lock | Locking for classic conda workflows |
| micromamba | C++ fast conda client (parallel effort) |
| conda-forge | Increasingly builds with rattler-build |
Resources