Interview Prep/Python for DevOps/Environments, dependencies & packaging

`requirements.txt` vs `pyproject.toml`: what goes where?

IntermediateConceptEnvironments, dependencies & packaging
Answer
  • pyproject.toml (PEP 621) declares the project: name, version, Python requirement, abstract dependencies with ranges (boto3>=1.35), optional extras, entry points, and tool config (ruff, mypy, pytest).
  • A lock file or a fully pinned requirements.txt records the exact resolved versions of everything, including transitive dependencies, for reproducible installs.

Libraries publish ranges; applications and Docker images install from a lock. We generate the lock with pip-compile (pip-tools), uv pip compile or uv lock, and commit it.

All Python for DevOps questions Roadmap: Python for automation

More on Environments, dependencies & packaging