Why Use Workspaces?
Workspaces solve several development challenges:- Local development - Work on multiple packages simultaneously
- Source dependencies - Depend on unreleased versions
- Monorepo support - Manage related packages in one repository
- Cross-language projects - Mix Python, C++, Rust, and more
- Shared configuration - Common channels, platforms, and settings
Normally, conda packages come pre-built from channels. Workspaces let you depend on the source code directly, which is built automatically as needed.
Creating a Multi-Package Workspace
workspace/
├── pixi.toml # Workspace + python_rich package
├── pyproject.toml # Python package metadata
├── src/
│ └── python_rich/
│ └── __init__.py
└── packages/
└── cpp_math/ # C++ package
├── pixi.toml
├── CMakeLists.txt
└── src/
└── math.cpp
[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]
preview = ["pixi-build"]
[dependencies]
python_rich = { path = "." }
[tasks]
start = "rich-example-main"
[package]
name = "python_rich"
version = "0.1.0"
[package.build]
backend = { name = "pixi-build-python", version = "0.4.*" }
[package.host-dependencies]
hatchling = "==1.26.3"
[package.run-dependencies]
cpp_math = { path = "packages/cpp_math" } # (1)!
rich = "13.9.*"
The root manifest contains both:
- Workspace configuration - Shared across all packages
- Package definition - For the
python_richpackage
[package]
name = "cpp_math"
version = "0.1.0"
[package.build]
backend = { name = "pixi-build-cmake", version = "0.3.*" }
[package.host-dependencies]
cmake = "3.20.*"
nanobind = "2.4.*"
python = "3.12.*"
Sub-packages inherit workspace settings from the root, so you don’t need to repeat channels, platforms, or preview settings.
from dataclasses import dataclass, fields
from rich.console import Console
from rich.table import Table
import cpp_math # (1)!
@dataclass
class Person:
name: str
age: int
city: str
def main() -> None:
console = Console()
people = [
Person("John Doe", 30, "New York"),
Person("Jane Smith", 25, "Los Angeles"),
Person("Tim de Jager", 35, "Utrecht"),
]
table = Table()
for column in fields(Person):
table.add_column(column.name)
for person in people:
updated_age = cpp_math.add(person.age, 1) # (2)!
table.add_row(person.name, str(updated_age), person.city)
console.print(table)
Workspace Patterns
Python-Only Workspace
Multiple Python packages:pixi.toml
src/root/pyproject.toml
- Depend on another package in the workspace
src/depend/pyproject.toml
- External conda dependencies
Workspace with Dev Dependencies
Use[dev] instead of [dependencies] to install only build-time dependencies:
pixi.toml
[dev]installs build and host dependencies but not the package itself
When to use [dev] vs [dependencies]?
When to use [dev] vs [dependencies]?
Use
[dependencies] when:- You want the built package installed in the environment
- You’re creating a library for others to use
- You need to test the installed package
[dev] when:- You only need build-time dependencies
- You’re developing the package and don’t need it installed
- You want faster iteration without package installation
Complete Workspace Example
Here’s the C++ package configuration:packages/cpp_math/CMakeLists.txt
packages/cpp_math/src/math.cpp
Workspace Commands
Advanced Workspace Configuration
Multiple Workspace Packages
You can have multiple packages at the root level:pixi.toml
Workspace with Variants
Build packages against multiple versions:pixi.toml
- Define allowed Python versions
- Create environments for each variant
Best Practices
Organize packages logically
Organize packages logically
Group related packages:
Use consistent versions
Use consistent versions
Keep package versions synchronized:
Minimize workspace configuration
Minimize workspace configuration
Keep sub-packages minimal - they inherit from the workspace:
packages/subpkg/pixi.toml
Document dependencies
Document dependencies
Comment why packages depend on each other:
Next Steps
Build Variants
Build against multiple dependency versions
Dependency Types
Understand build, host, and run dependencies
Package Sources
Use git, path, or URL sources
Python Packages
Build Python packages in workspaces
Troubleshooting
Package not found
Package not found
Ensure the path is correct relative to the workspace root:
Circular dependencies
Circular dependencies
Pixi doesn’t support circular dependencies between packages. Restructure to have a clear dependency hierarchy.
Build order issues
Build order issues
Pixi automatically determines build order based on dependencies. If builds fail, check that all dependencies are properly declared.
Workspace settings not inherited
Workspace settings not inherited
Only packages within the same workspace root inherit settings. External path dependencies don’t inherit workspace configuration.