Pixi Package Management
Complete guide for using pixi in the chem-validator project.
First Time Setup
Clone the repository and install environment:
cd chem-validator pixi install
This command:
- •Installs Python 3.13
- •Installs all dependencies (pandas, pubchempy, pytest, etc.)
- •Creates isolated
.pixi/environment - •Generates
pixi.lockfile for reproducibility
Running Tasks
All available tasks are defined in pixi.toml. Use pixi run <task-name>:
Development Tasks
# Launch GUI pixi run gui # Run CLI validator pixi run cli input.csv pixi run cli input.csv --output-folder auto pixi run cli input.csv --output-folder /custom/path
Testing Tasks
# Run all tests pixi run test # Run only fast tests (marked with @pytest.mark.fast) pixi run test-fast # Run only slow tests (integration tests) pixi run test-slow # Run tests with coverage report (HTML + terminal) pixi run test-coverage # Check if coverage meets 80% threshold (used in pre-commit) pixi run coverage-check
Build Tasks
# Build standalone executable pixi run build # Clean build artifacts pixi run clean
Pre-commit Tasks
# Install pre-commit hooks (first time only) pixi run install-hooks # Run all pre-commit hooks manually pixi run run-hooks
Adding Dependencies
Add a new Python package:
pixi add <package-name>
Examples
# Add numpy pixi add numpy # Add requests library pixi add requests # Add pytest plugin pixi add pytest-xdist # Add with specific version pixi add "numpy>=1.24.0"
This automatically:
- •Updates
pixi.toml[dependencies] section - •Updates
pixi.lockwith resolved versions - •Installs the package in the environment
Creating New Tasks
Edit pixi.toml and add to the [tasks] section:
Simple Command
[tasks] my-task = "python my_script.py"
Complex Task with Description
[tasks]
my-complex-task = { cmd = "pytest && python build.py", description = "Run tests and build" }
Then run:
pixi run my-task
Environment Management
List Installed Packages
pixi list
Update Dependencies
Update all packages to latest compatible versions:
pixi update
View Environment Info
pixi info
Shows Python version, platform, channels, and package count.
Activate Shell (Optional)
Enter the pixi environment in your shell:
pixi shell
Now you're inside the environment:
python --version # Shows 3.13.x which python # Points to .pixi/envs/.../bin/python
Exit with exit or Ctrl+D.
Common Workflows
Daily Development
# Test changes in GUI pixi run gui # Quick test check pixi run test-fast # Commit (pre-commit hooks run automatically) git add . git commit -m "feat(gui): add new feature"
Before Committing
# Run all tests pixi run test # Verify coverage threshold pixi run coverage-check # Test that build works pixi run build
Release Workflow
# Ensure all tests pass pixi run test # Build executable pixi run build # Test the executable manually ./dist/chem-validator.exe # Windows ./dist/chem-validator.app # macOS # Commit and tag git commit -m "chore: release v0.2.0" git tag v0.2.0
Understanding pixi.lock
The pixi.lock file:
- •Locks exact versions of all dependencies
- •Ensures reproducible builds across machines
- •Should be committed to git
- •Auto-generated (don't edit manually)
If dependencies change, pixi automatically updates the lock file.
Troubleshooting
Lock File Out of Sync
If you get lock file errors:
# Force reinstall pixi install --locked=false
Clean Environment
Remove environment and reinstall:
# Clean pixi environment pixi clean # Reinstall from scratch pixi install
Remove Everything
Complete reset:
rm -rf .pixi pixi.lock pixi install
Dependency Conflicts
If packages conflict:
# Check what's installed pixi list # Remove problematic package # Edit pixi.toml to remove the package line, then: pixi install
Platform-Specific Notes
Windows
# Use PowerShell or cmd pixi run gui # Build executable pixi run build # Creates: dist/chem-validator.exe
macOS
# Terminal pixi run gui # Build executable pixi run build # Creates: dist/chem-validator.app
Linux
pixi run gui # Note: PyInstaller creates binary (not .app bundle) pixi run build # Creates: dist/chem-validator
Advanced: Custom Python Version
To use a different Python version, edit pixi.toml:
[dependencies] python = "3.12.*" # Changed from 3.13.*
Then:
pixi install
Pixi vs pip/conda
Why pixi?
- •Single tool for Python version + packages
- •Faster than conda
- •Better lock files than pip
- •Cross-platform consistency
- •No separate virtual environment activation needed
Don't use:
- •
pip install- Usepixi addinstead - •
conda install- Usepixi addinstead - •
venvorvirtualenv- Pixi handles environments
Quick Reference
# Setup pixi install # First time setup # Development pixi run gui # Launch GUI pixi run cli input.csv # Run CLI # Testing pixi run test # All tests pixi run test-fast # Fast tests only pixi run test-coverage # With coverage report # Package Management pixi add <package> # Add package pixi list # List packages pixi update # Update all packages # Building pixi run build # Build executable pixi run clean # Clean artifacts # Environment pixi shell # Activate environment pixi info # Show environment info pixi clean # Clean environment
Getting Help
# General help pixi --help # Task-specific help pixi run --help # List all available tasks pixi task list