1. Workflow: uv pip + requirements.txt

How it works:

  • Direct, pip-compatible workflow.
  • You manually manage requirements.txt.

Typical commands:

bash
# Install a package (does NOT update requirements.txt)
uv pip install requests

# Update requirements.txt to reflect all installed packages (overwrites file!)
uv pip freeze > requirements.txt

# Install all packages from requirements.txt
uv pip install -r requirements.txt

# Sync the environment to match requirements.txt exactly
uv pip sync requirements.txt

Note: No command will automatically update requirements.txt when you install a package.
You need to update the file yourself, either by editing it manually or by running uv pip freeze.


2. Workflow: uv add + pyproject.toml (Modern Project Mode)

How it works:

  • Modern, reproducible workflow (like Poetry/PDM).
  • pyproject.toml and uv.lock are updated for you.

Typical commands:

bash
# Add a package and auto-update pyproject.toml & uv.lock
uv add requests

# Remove a package and auto-update pyproject.toml & uv.lock
uv remove requests

# Sync the virtual environment with pyproject.toml & uv.lock
uv sync

# Upgrade dependencies to latest allowed by constraints
uv update
  • uv add and uv remove will automatically update both pyproject.toml and uv.lock for you.
  • uv sync installs exactly the packages and versions specified in uv.lock.

Summary Table

Workflow Install Command Install All Remove Update Dependency List?
uv pip + requirements uv pip install ... uv pip install -r requirements.txt โ€” โŒ (manual or uv pip freeze)
uv add + pyproject.toml uv add ... uv sync uv remove ... โœ… (automatic)

Choose uv pip + requirements.txt for legacy/simple projects.

Choose uv add + pyproject.toml for modern, reproducible Python project management.


Published

Category

Tech

Tags

Contact