Zum Inhalt springen

rattler - Rust Conda Package Management Library Cheatsheet

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

KomponenteZweck
rattler (Crates)Libraries: Repodata, Solver, Installer
rattler-buildBuild Conda Packages aus Recipes
rattler-indexGenerate Channel Repodata
resolvoDas SAT Dependency Solver

Installing Rattler-Build

MethodeBefehl
Cargocargo install rattler-build
Pixipixi global install rattler-build
Condaconda install -c conda-forge rattler-build
BinaryDownload von GitHub Releases
Verifikationrattler-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
BefehlBeschreibung
rattler-build build --recipe FILEBuild das Package
rattler-build build -r . --target-platform linux-64Cross-Platform Target
rattler-build test --package-file X.condaRun die Recipe’s Tests
rattler-build uploadPublish zu einem Channel
--output-dir DIRWo Gebaut Artifacts landen

Recipe Format (v1) Highlights

SectionZweck
packageName und Version
sourceURL/Git + Checksum oder Lokaler Path
buildBuild Number, Script, Skip Conditions
requirementsbuild / host / run / run_constraints
testsImport, Script und Package-Content Tests
aboutLicense, Homepage, Summary
contextVariables 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
CrateProvides
rattler_repodata_gatewayFetch/Cache Channel Repodata
rattler_solveDependency Resolution (Resolvo)
rattler_installs_packagesInstalliere in ein Prefix
rattler_conda_typesCore Types (MatchSpec, RepoData)

Rattler-Build vs Conda-Build

AspektRattler-BuildConda-Build
LanguageRustPython
SpeedViel SchnellerSlower
Recipe Formatv1 recipe.yamlmeta.yaml
DependenciesStandalone BinaryRequires Conda/Python
Am besten fürNeue Recipes, CI SpeedLegacy Recipes

Wo Rattler passt

ToolRelationship
PixiBuilt auf Rattler
conda-lockLocking für klassische Conda Workflows
MicromambaC++ schnell Conda Client (Parallel Effort)
Conda-ForgeIncreasingly Builds mit Rattler-Build

Ressourcen