What is the difference between a loosely-pinned `requirements.txt` and a fully-locked dependency file, and why does reproducibility matter?
Answer
A loosely-pinned requirements file (`requests>=2.20`) only names direct dependencies and leaves their exact resolved versions, and every transitive dependency's version, up to whatever `pip` happens to resolve at install time, which can differ between two installs done weeks apart as new versions are published. A fully-locked file pins every package, direct and transitive, to an exact version (and often a content hash), which guarantees the same declared artifacts install consistently within the environments that lock file was actually built for — a given Python version, OS and architecture, with the locked source or wheel artifacts still available. It does not by itself guarantee an identical result on every machine or forever into the future: platform-specific wheels, environment markers, and artifacts that later become unavailable from an index can still make outcomes vary across genuinely different environments or across time. `pylock.toml` (PEP 751) is the current standardized, tool-agnostic lock file format built specifically for reproducible installs within a declared set of compatible environments. Reproducibility within those bounds is still essential for consistent builds, debugging "works on my machine" issues, and safe rollbacks.
Strong answer includes
- loose pins leave exact resolved and transitive versions up to install-time resolution
- a lock file pins every package to an exact version/hash, reproducible within its declared compatible environments — not an unconditional forever-and-anywhere guarantee
- pylock.toml (PEP 751) is the current standardized lock file format for this
Practical example
A CI pipeline that installs from a loose `requirements.txt` can start failing overnight when an unrelated transitive dependency ships a breaking change, while a locked file keeps builds stable until someone deliberately updates it.