Skip to content

rattler - Rust Conda Package Management Library Cheatsheet

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

ComponentPurpose
rattler (crates)Libraries: repodata, solver, installer
rattler-buildBuild conda packages from recipes
rattler-indexGenerate channel repodata
resolvoThe SAT dependency solver

Installing rattler-build

MethodCommand
Cargocargo install rattler-build
pixipixi global install rattler-build
condaconda install -c conda-forge rattler-build
Binarydownload from GitHub Releases
Verifyrattler-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
CommandDescription
rattler-build build --recipe FILEBuild the package
rattler-build build -r . --target-platform linux-64Cross-platform target
rattler-build test --package-file X.condaRun the recipe’s tests
rattler-build uploadPublish to a channel
--output-dir DIRWhere built artifacts land

Recipe Format (v1) Highlights

SectionPurpose
packageName and version
sourceURL/git + checksum, or local path
buildBuild number, script, skip conditions
requirementsbuild / host / run / run_constraints
testsImport, script, and package-content tests
aboutLicense, homepage, summary
contextVariables 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
CrateProvides
rattler_repodata_gatewayFetch/cache channel repodata
rattler_solveDependency resolution (resolvo)
rattler_installs_packagesInstall into a prefix
rattler_conda_typesCore types (MatchSpec, RepoData)

rattler-build vs conda-build

Aspectrattler-buildconda-build
LanguageRustPython
SpeedMuch fasterSlower
Recipe formatv1 recipe.yamlmeta.yaml
DependenciesStandalone binaryRequires conda/Python
Best forNew recipes, CI speedLegacy recipes

Where rattler Fits

ToolRelationship
pixiBuilt on rattler
conda-lockLocking for classic conda workflows
micromambaC++ fast conda client (parallel effort)
conda-forgeIncreasingly builds with rattler-build

Resources