rattler - Rust Conda Package Management Library Cheatsheet
rattler ist ein Set von Rust Libraries und Tools zum Arbeiten mit dem Conda Packaging Ökosystem, gebaut von prefix.dev. Es reimplementiert Conda’s Core-Operationen — parsing Repodata, Resolving Dependencies, Downloading und Installing Packages — mit einem schnellen Solver (Resolvo) und kein Python Abhängigkeit. Es ist das Engine unterhalb Pixi, und sein Companion rattler-build ist ein Moderner Ersatz für Conda-Build, der Packages aus einem Declarative Recipe konstruiert.
Komponenten
| Komponente | Zweck |
|---|
rattler (Crates) | Libraries: Repodata, Solver, Installer |
rattler-build | Build Conda Packages aus Recipes |
rattler-index | Generate Channel Repodata |
| resolvo | Das SAT Dependency Solver |
Installing Rattler-Build
| Methode | Befehl |
|---|
| Cargo | cargo install rattler-build |
| Pixi | pixi global install rattler-build |
| Conda | conda install -c conda-forge rattler-build |
| Binary | Download von GitHub Releases |
| Verifikation | rattler-build --version |
Bauen eines Packages
# 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
| Befehl | Beschreibung |
|---|
rattler-build build --recipe FILE | Build das Package |
rattler-build build -r . --target-platform linux-64 | Cross-Platform Target |
rattler-build test --package-file X.conda | Run die Recipe’s Tests |
rattler-build upload | Publish zu einem Channel |
--output-dir DIR | Wo Gebaut Artifacts landen |
| Section | Zweck |
|---|
package | Name und Version |
source | URL/Git + Checksum oder Lokaler Path |
build | Build Number, Script, Skip Conditions |
requirements | build / host / run / run_constraints |
tests | Import, Script und Package-Content Tests |
about | License, Homepage, Summary |
context | Variables Wiederverwendbar via Jinja |
context:
version: "1.0.0"
package:
name: mypackage
version: ${{ version }}
Variants (Build Matrices)
# variants.yaml — build gegen mehrere Python Versionen
python:
- "3.11"
- "3.12"
rattler-build build --recipe recipe.yaml --variant-config variants.yaml
Using die Rust Libraries
// Conceptual: Resolve und Installiere eine Environment Programmatically
use rattler_solve::{SolverImpl, SolverTask};
// 1) fetch Repodata für die Channels
// 2) build ein SolverTask mit deinen Specs
// 3) solve → List von Package Records
// 4) Installiere in ein Prefix mit Rattler's Installer
| Crate | Provides |
|---|
rattler_repodata_gateway | Fetch/Cache Channel Repodata |
rattler_solve | Dependency Resolution (Resolvo) |
rattler_installs_packages | Installiere in ein Prefix |
rattler_conda_types | Core Types (MatchSpec, RepoData) |
Rattler-Build vs Conda-Build
| Aspekt | Rattler-Build | Conda-Build |
|---|
| Language | Rust | Python |
| Speed | Viel Schneller | Slower |
| Recipe Format | v1 recipe.yaml | meta.yaml |
| Dependencies | Standalone Binary | Requires Conda/Python |
| Am besten für | Neue Recipes, CI Speed | Legacy Recipes |
Wo Rattler passt
| Tool | Relationship |
|---|
| Pixi | Built auf Rattler |
| conda-lock | Locking für klassische Conda Workflows |
| Micromamba | C++ schnell Conda Client (Parallel Effort) |
| Conda-Forge | Increasingly Builds mit Rattler-Build |
Ressourcen