8000 PEP 751: A file format to list Python dependencies for installation reproducibility by brettcannon · Pull Request #3870 · python/peps · GitHub
[go: up one dir, main page]

Skip to content

PEP 751: A file format to list Python dependencies for installation reproducibility #3870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 59 commits into from
Jul 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5e9e274
Write up to the specification
brettcannon Mar 20, 2024
f4fc728
Tweak rationale
brettcannon Mar 21, 2024
68a6dcd
Write down the file format
brettcannon Mar 21, 2024
761922e
Add in the `[[tool]]` table array
brettcannon Mar 21, 2024
61a72f5
Add expectations for lockers
brettcannon Mar 21, 2024
86e44fa
Add expectations for installers for per-file locking
brettcannon Mar 21, 2024
a960f76
Add some clarifications
brettcannon Mar 21, 2024
08f59d3
Example workflow for package locking
brettcannon Mar 22, 2024
82393b2
Bit of a clarification
brettcannon Mar 22, 2024
8c6801d
Add `package.tool`
brettcannon Mar 23, 2024
6b188ba
Add `package.dependents`
brettcannon Mar 23, 2024
6cced99
Fix a typo
brettcannon Mar 23, 2024
0080fc2
Add `package.description`
brettcannon Mar 23, 2024
1214a78
Add `package.direct`, `package.directory`, and `package.multiple-entr…
brettcannon Mar 25, 2024
92de818
Rename `package.simple-repo-package-url` and add `package.files.simpl…
brettcannon Mar 26, 2024
619bd6e
Updates based on some review comments
brettcannon Mar 28, 2024
244957c
Use a fake PEP number to make CI happy
brettcannon Mar 28, 2024
6a92b8f
Add an explicit note that the directory to write a `pylock.toml` file…
brettcannon Mar 28, 2024
2eb7166
Make the hash algorithm its own setting
brettcannon Mar 29, 2024
3623ccf
Fill out the ACKS section
brettcannon Mar 29, 2024
22fc531
Outline rejected ideas
brettcannon Mar 29, 2024
3182912
Add a rejected idea
brettcannon Mar 30, 2024
0e1df0c
Record the rejected idea of new core metadata version for metadata co…
brettcannon May 24, 2024
48811ee
Answer the rejected idea of having the installer do resolution
brettcannon May 25, 2024
b1c2fdc
Fill in rejected ideas around file names
brettcannon May 25, 2024
135a13e
Add rejected ideas around the file format
brettcannon May 27, 2024
450a50f
Finish filling in the rejected ideas
brettcannon May 27, 2024
aa7840f
Minor tweaks
brettcannon May 31, 2024
f6b02ef
Finish proofreading
brettcannon Jun 7, 2024
b35057a
Clarify that installers should never guess which `[[file-lock]]` to i…
brettcannon Jul 11, 2024
c16848b
reST fix
brettcannon Jul 11, 2024
15b2c05
Fix reST links
brettcannon Jul 11, 2024
040fa85
Add a TOML link target
brettcannon Jul 11, 2024
902ab69
Clarify that the file format is designed to facilitate diff reading
brettcannon Jul 23, 2024
c2677c1
Merge branch 'main' of github.com:python/peps into lock-file
brettcannon Jul 24, 2024
e1ec016
Refer to PoCs
brettcannon Jul 24, 2024
08e6fdb
Tweak some wording
brettcannon Jul 24, 2024
a3a1485
Pick a PEP number
brettcannon Jul 24, 2024
462b7e0
Update CODEOWNERS
brettcannon Jul 24, 2024
53a0ba6
Merge branch 'main' into lock-file
brettcannon Jul 24, 2024
75d6615
Clean up CODEOWNERS
brettcannon Jul 24, 2024
beaee5c
Merge branch 'lock-file' of https://github.com/brettcannon/peps into …
brettcannon Jul 24, 2024
dec8120
Fix lint failures
brettcannon Jul 24, 2024
a4d1840
Fix another lint failure
brettcannon Jul 24, 2024
b0d4877
Nest sections more
brettcannon Jul 24, 2024
1b39e49
Accept/address some comments
brettcannon Jul 24, 2024
9031e5c
Apply suggestions from code review
brettcannon Jul 24, 2024
fd139c3
Apply suggestions from code review
brettcannon Jul 24, 2024
89ff321
Apply suggestions from code review
brettcannon Jul 24, 2024
a914c12
Apply suggestions from code review
brettcannon Jul 24, 2024
8c21909
Adam likes periods
brettcannon Jul 24, 2024
98b4e82
More details around hashing
brettcannon Jul 24, 2024
e27b73d
Clarify `package.direct` defaults to `false`
brettcannon Jul 24, 2024
c0d46a1
Specify ``[[package.files]]` should be sorted by name
brettcannon Jul 24, 2024
0c45e87
Clarify that `[[package.build-requires]]` is locked
brettcannon Jul 24, 2024
ce18c5c
Clean up a sentence
brettcannon Jul 24, 2024
f5b574e
Fix a section title
brettcannon Jul 24, 2024
17ce7cd
Tweak abstract
brettcannon Jul 24, 2024
6df00c5
Merge branch 'main' into lock-file
brettcannon Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Write up to the specification
  • Loading branch information
brettcannon committed Mar 20, 2024
commit 5e9e27461685738b237bd47538974765f9c7bbba
158 changes: 158 additions & 0 deletions peps/pep-9999.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
PEP: <REQUIRED: pep number>
Title: A file format to list Python dependencies for installation reproducibility
Author: Brett Cannon <brett@python.org>
PEP-Delegate: <PEP delegate's real name>
Discussions-To: <REQUIRED: URL of current canonical discussion thread>
Status: Draft
Type: Standards Track
Topic: Packaging
Created: <date created on, in dd-mmm-yyyy format>
Post-History: <REQUIRED: dates, in dd-mmm-yyyy format, and corresponding links to PEP discussion threads>
Replaces: 665

Abstract
========

[A short (~200 word) description of the technical issue being addressed.]

This PEP proposes a new file format for specifying what dependencies to
(possibly) install into a Python environment for consitent installation
repoducibility. The format is designed to be human-readable but
machine-generated. Installers consuming the file should also not need to resolve
which listed dependencies to install, but instead evaluate each dependency in
question in isolation.


Motivation
==========

Currently, there is no standard way to specify what top-level dependencies one
would like to see installed into a Python environment and then subsequently
record what war eventually installed in a file (called a *lock file*).
Considering there are four well-known solutions to this problem in the
community (``pip freeze``, pip-tools_, Poetry_, and PDM_), there seems to be an
appetite for lock files in general.

Those tools also vary in what locking scenarios they approach. For instance,
``pip freeze`` and pip-tools only generate lock files for the current
environment while PDM and Poetry try to lock for *any* environment to some
degree. And none of them directly support locking to specific files to install
which can be important for some workflows. There's also concerns around secure
defaults in the face of supply chain attacks. Finally, not all the formats are
easy to audit to determine what what would be installed into an environment
ahead of time.

Ghe lack of a standard also has some drawbacks. For instance, any tooling that
wants to work with lock files must choose which format to support, potentially
leaving users unsupported (e.g. if Dependabot_ chose not to support PDM.
support by cloud providers who can do dependency installations on your behalf,
etc.).


Rationale
=========

[Describe why particular design decisions were made.]

The file format is designed to be human-readable. This is
so that the contents of the file can be audited by a human to make sure no
undesired dependencies end up being included in the lock file. It is also to
facilitate understanding what would be installed if the lock file were to be
used without necessitating running a tool, once again to help with auditing.

The file format is also designed to not require a resolver at install time. Being
able to analyze dependencies in isolation from one another when listed in a lock
file provides a few benefits. First, it supports auditing by making it easy to
figure out if a certain dependency would be installed for a certain environment.
It should also lead to faster installs which are much more frequent than
creating a lock file. Finally, the four tools mentioned in the Motivation
section either already implement this approach of evaluating dependencies in
isolation or have suggested they could in
`Poetry's case <https://discuss.python.org/t/lock-files-again-but-this-time-w-sdists/46593/83>`__.

The lock file format is designed to support two locking scenarios. The first is
locking to specific files for an environment. This is to support workflows where
the environment(s) are known ahead of time and specifying what exactly to
install is important. This is similar to what ``pip freeze`` and pip-tools_
support, but with more strictness of the exact files as well as incorporating
into the file format the ability to specify the locked files for multiple
environments.

The second locking scenario is to lock to package versions. This is the approach
taken by PDM_ (and indirectly by Poetry_). This is to support workflows where
the environment(s) are not known ahead of time. This can happen in open source
projects where contributors can have a myriad of different environments but
there's a desire to lock the packages used for e.g. building the project's
documentation. Since trying to lock the files for all possible environments
could be tedious at best and very expensive at worst, locking to the package
acts as a pragmatic compromise.


Specification
=============

[Describe the syntax and semantics of any new language feature.]

XXX core metadata 2.4

XXX file name

XXX file format

XXX expectations for lockers

XXX expectations for installers

Backwards Compatibility
=======================

[Describe potential impact and severity on pre-existing code.]


Security Implications
=====================

[How could a malicious user take advantage of this new feature?]


How to Teach This
=================

[How to teach users, new and experienced, how to apply the PEP to their work.]


Reference Implementation
========================

[Link to any existing implementation and details about its state, e.g. proof-of-concept.]


Rejected Ideas
==============

[Why certain ideas that were brought while discussing this PEP were not ultimately pursued.]


Open Issues
===========

[Any points that are still being decided/discussed.]


Footnotes
=========

[A collection of footnotes cited in the PEP, and a place to list non-inline hyperlink targets.]


Copyright
=========

This document is placed in the public domain or under the
CC0-1.0-Universal license, whichever is more permissive.


_Dependabot: https://docs.github.com/en/code-security/dependabot
_PDM: https://pypi.org/project/pdm/
_pip-tools: https://pypi.org/project/pip-tools/
_Poetry: https://python-poetry.org/
0