| name | pkg-mgmt |
| description | Python package and environment management using uv and mamba. Use when installing packages, creating virtual environments, setting up new projects, or managing dependencies. NOT for general Python coding questions. |
Python Environment Skill (Comp Chem & AI Edition)
Default to uv for speed/ML; use mamba for heavy C++/Fortran binaries (e.g., OpenMM).
uv — Fast Project Management (Primary)
Best for: New projects, PyTorch/JAX, RDKit, CI/CD.
uv is an extremely fast Python package installer and resolver written in Rust.
Installation
curl -LsSf https://astral.sh/uv/install.sh | sh
brew install uv
Modern Workflow (Replaces pip/venv)
uv init my-project && cd my-project
uv python pin 3.11
uv add rdkit pandas torch
uv add --dev pytest ruff
uv sync
uv run python train_model.py
uv run pytest
The "Quick Experiment"
Run a script with dependencies ephemerally (no permanent env created):
uv run --with rdkit --with matplotlib molecular_vis.py
Legacy Workflow (pip-style)
uv venv
uv venv --python 3.11
source .venv/bin/activate
uv pip install rdkit scikit-learn pandas
uv pip install -r requirements.txt
uv pip install -e .
mamba — Complex Binaries (Secondary)
Best for: OpenMM, AmberTools, legacy projects, or strict system library requirements.
mamba is a fast, drop-in replacement for conda.
Installation
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh"
bash Miniforge3-MacOSX-arm64.sh
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh"
bash Miniforge3-MacOSX-x86_64.sh
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh"
bash Miniforge3-Linux-x86_64.sh
Reproducible Workflow
Always use environment.yml with conda-forge:
name: md-sim
channels:
- conda-forge
dependencies:
- python=3.11
- openmm
- ambertools
- rdkit
- numpy
- pandas
- pip
mamba env create -f environment.yml
mamba env update -f environment.yml --prune
mamba env export --no-builds > environment.yml
Quick Commands
mamba create -n myenv python=3.11
mamba activate myenv
mamba deactivate
mamba install rdkit numpy pandas
Decision Matrix: Chemist Edition
| Scenario | Tool | Reasoning |
|---|
| General ML / PyTorch | uv | 100x faster, handles wheels perfectly |
| Cheminformatics (RDKit) | uv | RDKit PyPI wheels are now stable |
| MD Sims (OpenMM/Amber) | mamba | Complex CUDA/C++ bindings are fragile on PyPI |
| Publishing/Sharing | uv | pyproject.toml is the modern standard (PEP 621) |
| Quick Scripts | uv | uv run --with enables single-file reproducibility |
| Legacy Projects | mamba | If it already uses Conda, stick with it |
The Hybrid Approach
Need mamba binaries (e.g., OpenMM) but want uv speed for everything else? Create the env with mamba, then use uv pip inside it:
mamba create -n hybrid-env openmm python=3.11 -c conda-forge
mamba activate hybrid-env
uv pip install torch rdkit scikit-learn
Best Practices
1. Lockfiles are Mandatory
uv lock
mamba env export --no-builds > environment.yml
2. pyproject.toml is Truth
Stop using requirements.txt. Define deps in pyproject.toml:
[project]
name = "my-project"
version = "0.1.0"
dependencies = [
"rdkit",
"numpy>=1.24",
"pandas>=2.0",
]
[project.optional-dependencies]
dev = ["pytest", "ruff"]
3. Strict Channels for Mamba
Avoid ABI conflicts by strictly prioritizing conda-forge:
conda config --add channels conda-forge
conda config --set channel_priority strict
4. Never Install to System Python
pip install rdkit
uv venv && source .venv/bin/activate && uv pip install rdkit
CI/CD Pipeline
- uses: astral-sh/setup-uv@v4
- run: uv sync
- run: uv run pytest