<#1309 feat(image): add pixi support via Image.wit...
# flyte-github
a
#1309 feat(image): add pixi support via Image.with_pixi_project Pull request opened by cosmicBboy Summary Adds first-class pixi support to
flyte.Image
, so images can be built from existing pixi projects (conda + PyPI packages resolved in a single solve). Implemented as a proper
Layer
+ builder handler following the existing uv/poetry conventions rather than composing `with_commands`/`with_source_file`. API image = flyte.Image.from_debian_base().with_pixi_project("path/to/pixi.toml")
with_pixi_project
mirrors
with_uv_project
/
with_poetry_project
and covers the ways a pixi user would point at existing artifacts: • Manifest formats: a
pixi.toml
, a
pyproject.toml
with
[tool.pixi]
, or the project directory itself (manifest discovered pixi-style:
pixi.toml
first, then
pyproject.toml
). • Lockfiles:
pixi.lock
next to the manifest is auto-detected (same pattern as
uv.lock
); when present the build runs
pixi install --locked
for reproducibility. An explicit
pixi_lock=
path is also accepted. • Named environments:
environment="prod"
selects a multi-environment manifest's env; it is installed and activated. • Full-project installs:
project_install_mode="install_project"
copies the whole project directory for manifests that install the project itself as an editable pypi dependency (the default
dependencies_only
copies only manifest + lock). •
extra_args
passthrough to
pixi install
and
secret_mounts
for private channels. How the build works (local docker builder) The handler copies a pinned pixi binary out of the official
ghcr.io/prefix-dev/pixi
image (same pattern as the pinned uv stage), copies the manifest and lock into
/opt/pixi-project
, and runs
pixi install
with a rattler cache mount. It then re-points
VIRTUAL_ENV
,
UV_PYTHON
,
PATH
, and
PIXI_PROJECT_MANIFEST
so the pixi environment becomes the image's runtime environment — and so subsequent
with_pip_packages
/
with_requirements
/ local-wheel layers install into the pixi env (e.g.
.with_pip_packages("flyte")
composes correctly). Because the project dir is stable across pixi layers, the reference prototype's layering pattern works out of the box: a second
with_pixi_project
with a superset manifest incrementally updates the same environment instead of re-solving from scratch. Like
from_uv_script
, the environment must provide
python
and
flyte
— declare
flyte
under
[pypi-dependencies]
(kept in the same pixi solve) or add
.with_pip_packages("flyte")
after the layer. The docstring also documents the
CONDA_OVERRIDE_CUDA
env-var pattern for manifests with CUDA
[system-requirements]
built on GPU-less machines. Remote builder The imagebuilder protobuf IDL has no pixi layer, so
_get_layers_proto
lowers each
PixiProject
into primitive layers the IDL already understands: apt packages (curl/ca-certificates/bzip2/git), a pinned pixi install via the official install script,
CopyConfig
for the manifest/lock (or the whole project dir), a
pixi install
Commands
layer carrying the layer's
secret_mounts
, and an
Env
layer activating the pixi environment. Both builders therefore work; the local builder keeps its nicer native handler (pinned
COPY --from
binary + rattler cache mount). Previously unmatched layer types were silently skipped, which would have produced an image missing the user's environment. Cache hashing
PixiProject.update_hash
folds in the manifest, lock file, selected environment, and extra args (or the dockerignore-filtered project tree in
install_project
mode), matching
UVProject
semantics so image tags change exactly when the resolved environment could. Example
examples/project_structures/pixi_project/
adds a runnable sample (manifest + task) and the project-structures README gains a pixi section, decision-tree branch, and pattern-table row. Test plan • 9 new unit tests: layer validation (naming rules, missing files), lock auto-detection, directory-manifest discovery, hash sensitivity (lock content, environment), docker handler output for dependencies-only / no-lock / named-env+extra-args / install-project (incl. dockerignore survival of manifest+lock), and the remote-builder error. •
uv run pytest tests/flyte/test_image.py tests/flyte/imagebuild/ tests/flyte/test_image_builder.py -m "not integration"
— 162 passed; the 2 failures in
test_image_build_engine.py
are pre-existing on
main
(fail with this change stashed). •
ruff check
/
ruff format --check
/
mypy
clean on all changed files (pre-commit
make fmt
+
make mypy
passed on commit). • End-to-end on a hosted cluster (demo.hosted) with the Union remote image builder (config as shipped:
builder: remote
, no registry): build completed in 47s to the backend default registry and the example task succeeded with correct output (
14.0
). For the dev test, the manifest's
flyte
pin temporarily pointed at this PR branch via a git pypi-dependency so the runtime SDK included pixi support. • End-to-end on the same cluster with the local docker builder (
builder: local
+ Docker Hub registry): built the
pixi_project
example image with the local docker builder (multi-arch amd64+arm64, pushed to Docker Hub) and ran the example task —
ActionPhase.SUCCEEDED
with the correct output (
14.0
). Two fixes came out of this: the pixi image tag pin (0.73.0 does not exist on ghcr — image tags lag pixi releases; pinned 0.72.2) and multi-arch manifest platform coverage (example manifest now declares
linux-64
+
linux-aarch64
, docstring documents the requirement). For the dev-mode test, the local dist wheel was layered into the pixi env via
.with_local_v2()
after the pixi layer — confirming the "later layers install into the pixi env" composition works. 🤖 Generated with Claude Code flyteorg/flyte-sdk