Overview
Package dependencies in Pixi are more granular than workspace dependencies. While workspace dependencies are simply packages available in environments, package dependencies distinguish between when and where they’re needed:Think of it this way:
- Build dependencies run on your machine during compilation
- Host dependencies are compiled into your package
- Run dependencies are needed when using your package
Build Dependencies
Build dependencies are tools needed to build the package, installed for the architecture of the build machine.When to Use Build Dependencies
Use for tools that:- Run during compilation but aren’t compiled into the package
- Generate code or resources
- Are specific to your development machine
Common Examples
Cross-Compilation Example
Build dependencies enable cross-compilation:- Build platform: Your machine (e.g.,
osx-arm64) - Host/target platform: Where the code runs (e.g.,
linux-aarch64)
Understanding build machine terminology
Understanding build machine terminology
The terminology comes from cross-compilation:
For most builds, build = host = target.
| Machine | Definition | Example |
|---|---|---|
| Build | Where compilation happens | Your MacBook (osx-arm64) |
| Host | Where the code runs | Linux server (linux-64) |
| Target | For compilers: what they generate code for | ARM device (linux-aarch64) |
Host Dependencies
Host dependencies are needed during build/link time and are specific to the target platform.When to Use Host Dependencies
Use for:- Libraries you link against
- Headers you include
- Base interpreters (Python, R, Node.js)
- Build backends for interpreted languages
Common Examples
Python Build Backends
Python build tools must go inhost-dependencies due to technical limitations:
Native Code Libraries
When building C++ or other native code:Cross-Compilation Scenario
Compiling on Linux x86_64 for Linux ARM:| Component | Type | Build | Host | Target |
|---|---|---|---|---|
| GCC | Compiler | x86_64 | x86_64 | aarch64 |
| CMake | Build tool | x86_64 | x86_64 | N/A |
| SDL2 | Library | N/A | aarch64 | N/A |
| Your App | Application | x86_64 | aarch64 | N/A |
Run-Exports
Many conda packages definerun-exports, which automatically add run dependencies:
Most conda-forge packages have
run-exports defined. When you add them to host-dependencies, they’re automatically added to run-dependencies - no need to specify twice!Run Dependencies
Run dependencies (also just called “dependencies”) are required when using the package.When to Use Run Dependencies
Use for:- Libraries loaded at runtime
- Executables called by your package
- Resources needed during execution
Common Examples
Run Dependencies in Workspaces
Run dependencies are similar to workspace dependencies:Path Dependencies
Depend on other packages in your workspace:Complete Example
Here’s a C++ package with all three dependency types:pixi.toml
Python Package Example
pixi.toml
numpy appears in both host-dependencies (for headers during compilation of extensions) and run-dependencies (for runtime imports). This is common for packages with both C and Python components.Decision Guide
Use this flowchart to determine dependency type:Quick Reference Table
| Aspect | Build | Host | Run |
|---|---|---|---|
| When used | Compile time | Link time | Runtime |
| Platform | Build machine | Target machine | Target machine |
| Examples | cmake, compilers | libraries, headers | executables, libraries |
| Installed where | Build environment | Target package | User environment |
| Cross-compile | Build platform | Host platform | Host platform |
Common Patterns
C++ with Python Bindings
C++ with Python Bindings
Pure Python Package
Pure Python Package
Rust Package
Rust Package
Multi-language Package
Multi-language Package
Understanding Run-Exports
Run-exports automatically propagate dependencies:Run-exports prevent version mismatches between build and runtime. If you build against zlib 1.2.13, run-exports ensure users get a compatible version.
Best Practices
Start with minimal dependencies
Start with minimal dependencies
Add only what’s strictly needed:
Let run-exports work
Let run-exports work
Don’t duplicate host and run dependencies if run-exports exist:
Be specific about versions
Be specific about versions
Use version constraints appropriately:
Document special dependencies
Document special dependencies
Comment why dependencies exist:
Next Steps
Build Backends
How backends use different dependency types
Build Variants
How variants affect dependencies
C++ Packages
Dependency types in C++ builds
Python Packages
Dependency types in Python builds
Troubleshooting
Library not found during build
Library not found during build
Ensure it’s in host-dependencies:
Executable not found during build
Executable not found during build
Add to build-dependencies:
Runtime import errors
Runtime import errors
Add to run-dependencies:
Wrong architecture used
Wrong architecture used
Verify dependency type:
- Build deps use build platform
- Host deps use target platform