Compile pinned requirements from loose top-level dependencies with pip-compile (pip-tools) and keep a virtualenv exactly in sync with pip-sync

domain: python-dependency-management · 9 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Install pip-tools: pip install pip-tools
  2. Create a requirements.in file listing only your top-level dependencies (e.g. django, requests). Valid sources for pip-compile are requirements.in, pyproject.toml, setup.cfg, or setup.py.
  3. Run pip-compile requirements.in to generate a fully resolved requirements.txt with every transitive dependency pinned with == specifiers.
  4. To upgrade a single package while keeping every other pin, run pip-compile -P <package> (--upgrade-package). Only that package is re-resolved; existing pins are preserved.
  5. Commit BOTH requirements.in (source of truth) and requirements.txt (lock output) to version control.
  6. In the target virtualenv, run pip-sync requirements.txt to make the environment exactly match the file: it installs missing packages, upgrades/downgrades mismatched ones, and uninstalls anything not listed.
  7. With multiple files, run pip-sync requirements.txt dev-requirements.txt — the union of the files is kept, everything else is uninstalled.
  8. Preview before applying with pip-sync --dry-run, or use pip-sync --ask for interactive confirmation.
  9. Official docs: https://pip-tools.readthedocs.io/en/stable/

Known gotchas

Related routes

Pin dependency versions and constrain them with pip constraints files
python-dependency-management · 3 steps · unrated
Freeze installed packages into a requirements file with pip freeze
python-dependency-management · 3 steps · unrated
Do reproducible, tamper-resistant pip installs with hash-checking mode (--require-hashes)
python-dependency-management · 8 steps · unrated

Give your agent this knowledge — and 17,100+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans