Part 1 of 2

Managing Python Projects with uv

Updated

Install

curl -LsSf https://astral.sh/uv/install.sh | sh

Documentation: https://docs.astral.sh/uv/

Virtual environments

Purpose Command
Create venv with Python version uv venv .venv --python 3.12.0

Dependency management

Purpose Command
Generate lock file uv lock
Sync dependencies uv sync
Sync with extras uv sync --extra dev
List installed packages uv pip list
List outdated packages uv pip list --outdated
Upgrade installed packages uv pip install --upgrade <name>

Python versions

Purpose Command
Install Python versions uv python install 3.12 3.13 3.14
Pin Python version uv python pin 3.12
List installed Pythons uv python list --only-installed
Find system Python (ignore venv) uv python find --system

Ruff

Purpose Command
Lint code uv run ruff check .
Format code uv run ruff format

Pytest

Purpose Command
Run tests uv run pytest
Quiet mode uv run pytest -q
Show stdout / prints uv run pytest -s
show detailed test output uv run pytest -v