C.W.K.
Stream
Lesson 04 of 05 · published

pixi.toml, pixi.lock, Features, PyPI Layer

~11 min · pixi, concepts, internals

Level 0Newbie
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

Four pixi concepts cover most of the model.

pixi.toml. The project manifest. Declares the project name, channels, package deps (conda-forge), pypi-deps (PyPI), tasks, features, environments. It's pixi's package.json / Cargo.toml — the source of truth for what your project needs.

pixi.lock. The auto-generated lock file. Pins every direct and transitive dep with content hashes, for every platform you've targeted. Reproducibility is bit-exact — pixi install on another machine produces the same env. Always commit pixi.lock; never hand-edit.

Features and environments. pixi.toml supports declaring features (named groups of deps) and environments (combinations of features). The default usage is simple — base deps, plus a dev feature. But for complex projects you can have cuda, amd, cpu features and produce gpu-cuda, gpu-amd, cpu-only environments from one pixi.toml. That's monorepo-style reproducibility for ML projects.

PyPI layer via uv. When pixi.toml declares pypi-deps, pixi shells out to uv to resolve them. That's how pixi handles the conda-forge / PyPI split cleanly — conda-forge for binaries, uv for pure-Python packages. The two layers are tracked separately in pixi.lock, but the user-facing experience is unified.

Code

A real pixi.toml·toml
[project]
name = "my-ml-project"
version = "0.1.0"
channels = ["conda-forge", "pytorch"]
platforms = ["osx-arm64", "linux-64"]

[dependencies]
python = "3.12.*"
numpy = "*"
pandas = "*"
pytorch = "*"

[pypi-dependencies]
fastapi = "*"
pydantic = ">=2.0"

[tasks]
train = "python train.py"
serve = "uvicorn server:app --reload"

[feature.dev.dependencies]
pytest = "*"
ruff = "*"

[environments]
default = { features = [], solve-group = "default" }
dev = { features = ["dev"], solve-group = "default" }
Migrate from conda environment.yml·bash
# pixi can import conda environment.yml files
conda env export --from-history > environment.yml
pixi init --import environment.yml

# Generates a pixi.toml with the same packages.
# 'pixi install' to resolve and install.

External links

Exercise

If you have a conda environment.yml lying around, run 'pixi init --import environment.yml' in a fresh dir and read the resulting pixi.toml. The translation is mostly clean and you immediately see what pixi adds (tasks, features, lock).

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.