Python Establishes New Standard for Lock File Format to Boost Security
Python has officially adopted a standardized lock file format with the approval of PEP 751, marking a key advancement in the Python packaging ecosystem.
The newly introduced format, named pylock.toml, aims to resolve long-standing issues with dependency management. By standardizing how package versions, file hashes, and installation sources are recorded, it ensures consistent environments and improves security.
“Currently, there is no unified standard for creating a secure lock file that specifies which dependencies, both direct and indirect, should be installed in a virtual environment,” the PEP documentation states.
This gap has led to a fragmented landscape, with multiple popular solutions emerging, including PDM, pip freeze, pip-tools, Poetry, and uv.
The pylock.toml format is designed to be easily readable by humans but automatically generated by tools. It offers several advantages in terms of security when compared to older methods, like requirements files:

Enhanced Security Focus
Unlike traditional requirements.txt files, where file hash validation is optional, pylock.toml mandates hash values for every package, offering greater protection against supply chain vulnerabilities.
Additionally, the format tracks file sizes, upload timestamps, and package sources, making it easier to audit.
“The file format should promote secure defaults. Since it isn’t meant to be manually written, relying on tools to provide security-related information is reasonable and not burdensome,” the PEP explains.
The new specification introduces the idea of “lockers” (tools that create lock files) and “installers” (tools that install packages from lock files), helping to clearly separate the responsibilities of these tools.
This separation allows cloud hosting providers to create their own installers without needing a Python interpreter.
The pylock.toml format accommodates both single-use and multi-use lock files. Single-use files function similarly to requirements.txt, serving a particular purpose, while multi-use files handle several use cases in one, with support for extras and dependency groups.
Key features of each package entry include:
- Normalized package name
- Specific version
- Conditional installation based on environment markers
- Python version compatibility
- Hash values for verification
- File sizes for validation
- Upload timestamps for auditing
- Source locations (URLs or paths)
Brett Cannon, the creator of PEP 751, emphasizes that the new standard “supersedes PEP 665” and seeks to unify the ecosystem with a format supported by all tools.
With this move, Python joins other programming languages, including JavaScript (package-lock.json), Rust (Cargo.lock), and PHP (composer.lock), which already use established lock file formats.
For businesses and security teams, this standardization brings improved auditing, more reliable builds, and stronger defenses against dependency confusion attacks. By removing dependency resolution from the installation process, pylock.toml ensures faster and more predictable installations—critical for CI/CD pipelines and production environments.
As the PEP outlines, “Having the installer handle resolution also streamlines their implementation, centralizing complexity in the lockers,” which is expected to lead to more robust tooling across Python’s ecosystem.
Major Python packaging tools are anticipated to adopt the new format as their primary lock file format or export target, promoting greater interoperability and reducing the risk of vendor lock-in.




