Companion to
README.md. Covers uv project workflow, per-project ML dependencies, miniforge for GPU/binary workloads, and direnv integration.
| Tool | Use case | Replaces |
|---|---|---|
uv |
Pure Python projects, scripts, CLI tools, Python version management | pyenv + pip + venv + pipx |
miniforge (conda) |
ML workloads requiring non-Python binaries (MKL, HDF5, CUDA) | miniconda / anaconda |
Default to uv. Only reach for conda when a dependency requires compiled non-Python
binaries that aren't available as wheels (rare on Apple Silicon with modern PyPI).
Do not run pyenv and conda simultaneously — they both manipulate PATH and Python shims.
uv sidesteps this entirely.
uv init my-project
cd my-project
uv add numpy pandas # adds to pyproject.toml, installs into .venv
uv run script.py # runs in the project venvuv python install 3.12 # download and manage Python versions
uv python pin 3.12 # pin version for this project (.python-version)uv sync # installs all deps from uv.lock
uv sync --extra dev # include optional dev dependenciesuv add --dev pytest ruff mypy
uv add --optional ml torch transformersuvx ruff check . # ephemeral run — no install needed
uvx mypy src/These are per-project uv add dependencies, not global installs.
uv add modal # serverless GPU computeuv add mlflow # self-hosted experiment tracking
uv add wandb # Weights & Biasesuv add dvc # data and model versioning
uv add "dvc[s3]" # with S3 remote support
uv add "dvc[gs]" # with GCS remote supportuv add torch torchvision torchaudio # MPS-compatible build auto-selected
uv add transformers datasets accelerate
uv add langchain langgraph
uv add openai anthropicuv add google-cloud-aiplatform
uv add google-cloud-storageInstall only if a dependency requires non-Python binaries unavailable as wheels:
brew install --cask miniforge
conda config --set auto_activate_base false # don't pollute default shellCreate an isolated environment (never use base):
conda create -n myenv python=3.11
conda activate myenv
conda install pytorch torchvision -c pytorch # MKL / cuDNN buildsDeactivate when done — do not leave conda active in your default shell alongside uv.
direnv automatically loads and unloads env vars when you cd into a project directory.
Installed via Brewfile; the omz direnv plugin handles shell integration.
Create .envrc in the project root:
# .envrc
export DATABASE_URL="postgresql://localhost/mydb"
export API_KEY="..." # use secrets manager in production
export PYTHONPATH="src"Allow it:
direnv allow .# .envrc
layout uv # auto-creates and activates .venv via uvOr for an existing venv:
# .envrc
source .venv/bin/activate# .envrc
export CLOUDSDK_ACTIVE_CONFIG_NAME=dev
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/.config/gcloud/dev-adc.json"Commit .envrc if it contains no secrets — it documents the project's env requirements.
Never commit .env files.
[ ] uv init <project-name>
[ ] uv python pin <version>
[ ] uv add <dependencies>
[ ] uv add --dev pytest ruff mypy
[ ] echo ".venv/" >> .gitignore
[ ] touch .envrc && direnv allow .
[ ] git init && git add pyproject.toml uv.lock .python-version .gitignore