콘텐츠로 이동

rattler - Rust Conda 패키지 관리 라이브러리 치트시트

rattler - Rust Conda 패키지 관리 라이브러리 치트시트

rattler은 prefix.dev가 구축한 conda 패키징 생태계와 작동하기 위한 Rust 라이브러리 및 도구 세트입니다. conda의 핵심 운영 — repodata 파싱, 종속성 풀이, 패키지 다운로드 및 설치 — 빠른 솔버 (resolvo)와 Python 종속성 없이 다시 구현합니다. 이는 pixi 아래의 엔진이며, 그 동반자 **rattler-build**는 선언적 레시피에서 패키지를 구성하는 conda-build의 현대식 대체제입니다.

컴포넌트

컴포넌트목적
rattler (크레이트)라이브러리: repodata, 솔버, 설치자
rattler-build레시피에서 conda 패키지 빌드
rattler-index채널 repodata 생성
resolvoSAT 종속성 솔버

rattler-build 설치

방법명령
Cargocargo install rattler-build
pixipixi global install rattler-build
condaconda install -c conda-forge rattler-build
바이너리GitHub Releases에서 다운로드
확인rattler-build --version

패키지 빌드

# 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
명령설명
rattler-build build --recipe FILE패키지 빌드
rattler-build build -r . --target-platform linux-64크로스 플랫폼 대상
rattler-build test --package-file X.conda레시피의 테스트 실행
rattler-build upload채널에 게시
--output-dir DIR빌드된 아티팩트가 도착하는 곳

레시피 형식 (v1) 강조

섹션목적
package이름 및 버전
sourceURL/git + 체크섬, 또는 로컬 경로
build빌드 번호, 스크립트, 스킵 조건
requirementsbuild / host / run / run_constraints
tests임포트, 스크립트, 패키지 콘텐츠 테스트
about라이선스, 홈페이지, 요약
contextJinja를 통해 재사용 가능한 변수
context:
  version: "1.0.0"
package:
  name: mypackage
  version: ${{ version }}

변형 (빌드 매트릭스)

# variants.yaml — several Python versions에 대해 빌드
python:
  - "3.11"
  - "3.12"
rattler-build build --recipe recipe.yaml --variant-config variants.yaml

Rust 라이브러리 사용

// 개념적: 프로그래밍 방식으로 환경을 풀고 설치
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
크레이트제공
rattler_repodata_gateway채널 repodata 페치/캐시
rattler_solve종속성 풀이 (resolvo)
rattler_installs_packages접두사로 설치
rattler_conda_types핵심 타입 (MatchSpec, RepoData)

rattler-build vs conda-build

측면rattler-buildconda-build
언어RustPython
속도훨씬 빠름느림
레시피 형식v1 recipe.yamlmeta.yaml
종속성독립 실행형 바이너리conda/Python 필요
최고의 용도새로운 레시피, CI 속도기존 레시피

rattler이 맞는 곳

도구관계
pixirattler 위에 구축됨
conda-lock클래식 conda 워크플로 잠금
micromambaC++ 빠른 conda 클라이언트 (평행 노력)
conda-forge점점 더 rattler-build로 빌드

리소스