The pyjanitor project uses Pixi to manage multiple Python versions for testing. This is achieved through two main abstractions: Features and Environments.
1. Pixi Features
Features are reusable sets of dependencies. In pyproject.toml, features are defined to pin specific Python versions using semantic versioning with wildcards (e.g., 3.11.*).
2. Pixi Environments
Environments are named configurations that combine multiple features. An environment typically combines:
- Python version features (e.g.,
py311) - Testing features (e.g.,
tests containing pytest, hypothesis, etc.) - Setup features (e.g.,
setup for pre-commit hooks)
When an environment is created, Pixi resolves all dependencies from the combined features to create an isolated environment with the exact Python version specified.
[tool.pixi.feature.py311.dependencies]
python = "3.11.*"
[tool.pixi.environments]
py311 = { features = ["tests", "setup", "py311"] }