Skip to main content
Learn how to create build matrices that produce packages for different dependency versions, similar to parameterized builds or build configurations.
pixi-build is a preview feature and will change until stabilized. Keep this in mind when using it for your projects.

Why Use Build Variants?

Build variants solve version compatibility challenges:
  • Multiple Python versions - Support Python 3.11, 3.12, 3.13, etc.
  • Library versions - Build against different versions of dependencies
  • Testing - Verify compatibility across version ranges
  • Distribution - Provide packages for various configurations
In the conda ecosystem, this functionality is called “variants.” Other build systems might call this a build matrix, build configurations, or parameterized builds.

The Problem Variants Solve

Consider a C++ package built for Python 3.12:
If a user tries to use this package with Python 3.11, Pixi reports a version conflict. Variants allow you to build multiple versions of the package, each compatible with different Python versions.

Creating Build Variants

Complete Example

Here’s the full configuration:
pixi.toml
  1. Disable noarch to create variant-specific builds
  2. Allow any Python version - resolved by variants

Multiple Variant Dimensions

You can create variants for multiple dependencies:
This creates a build matrix:
  • Python 3.11 + nanobind 2.3
  • Python 3.11 + nanobind 2.4
  • Python 3.12 + nanobind 2.3
  • Python 3.12 + nanobind 2.4
  • Python 3.13 + nanobind 2.3
  • Python 3.13 + nanobind 2.4
Be careful with variant matrices - they grow exponentially! 3 Python versions × 2 nanobind versions × 4 platforms = 24 packages.

Variant Files

For complex configurations, use external variant files:
pixi.toml
variants.yaml
  1. Create paired variants instead of a full matrix
This creates only paired combinations:
  • Python 3.11 + nanobind 2.4
  • Python 3.12 + nanobind 2.5
  • Python 3.13 + nanobind 2.5
See the manifest reference for details.

Testing Across Variants

Run Tests in All Environments

Run Tasks in All Environments

Use a loop (bash):

Define Environment-Specific Tasks

Understanding Build Strings

Build strings indicate package variants:
Breakdown:
  • py311 - Python 3.11 variant
  • h43a39b2 - Hash of build configuration
  • _0 - Build number
Noarch packages (pure Python) have the same build string across variants:

Platform vs Variant Matrix

Platforms - Different OS/architectures:
Variants - Different dependency versions:
Combined: 3 platforms × 2 Python versions = 6 packages

Common Variant Patterns

Advanced: Conditional Variants

Use variant files for platform-specific variants:
variants.yaml

Best Practices

Begin with essential versions:
Make packages flexible:
Automate variant testing:
Explain why variants exist:

Next Steps

Dependency Types

Understand how variants affect dependencies

Workspaces

Use variants in multi-package workspaces

Build Backends

Backend-specific variant support

Manifest Reference

Complete variant configuration options

Troubleshooting

Check that:
  1. Package has noarch = false (or omit it)
  2. Dependency uses * or a range: python = "*"
  3. Variant is actually used in dependencies
Reduce variant dimensions:
Ensure environment pinning matches variants: