Skip to content

Add support for PEP 751 lockfiles #12584

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

Closed
charliermarsh opened this issue Mar 31, 2025 · 12 comments
Closed

Add support for PEP 751 lockfiles #12584

charliermarsh opened this issue Mar 31, 2025 · 12 comments
Assignees
Labels
enhancement New feature or improvement to existing functionality

Comments

@charliermarsh
Copy link
Member

charliermarsh commented Mar 31, 2025

PEP 751 is officially accepted.

Today, the PEP 751-style pylock.toml files are not sufficient to replace uv.lock. The biggest limitation is that there's no support for arbitrary entrypoints to the graph, because pylock.toml includes a fixed marker for each package entry rather than recording a graph of dependencies. Specifically, this means uv run -p could not be supported (i.e., we couldn't support installing a specific subset of the graph) within the standard.

Notably, though, unlike requirements.txt, pylock.toml also supports extras and dependency groups by extending the PEP 508 marker syntax. So markers can now express things like "this extra was enabled" or "this dependency group was enabled". As such, we could potentially use PEP 751-style pylock.toml files for single-member workspaces. I don't think this is worth the complexity right now, but it is possible.

So for now, from uv's perspective, we can think of PEP 751-style pylock.toml files as a more modern requirements.txt. A pylock.toml file captures a set of packages to install, along with the source of those packages. Unlike requirements.txt, the format is fully standardized, and it can also model certain pieces of information that requirements.txt cannot (e.g., you can specify a package as coming from a specific registry).

As a first step, we want to support PEP 751-style pylock.toml files as an export format in uv export, and as an installable format in uv pip install. Like uv pip install --group, we may want to see how pip chooses to support these files before implementing uv pip install support. This requires:

  • Adding code to translate uv.lock to pylock.toml in uv export.
  • Supporting pylock.toml as a dependency source for uv pip install, or maybe just uv pip sync?
  • Extending our PEP 508 implementation to understand the new extras and dependency-groups markers.
@charliermarsh charliermarsh added the enhancement New feature or improvement to existing functionality label Mar 31, 2025
@Gankra
Copy link
Contributor

Gankra commented Mar 31, 2025

@Gankra Gankra marked this as a duplicate of #5477 Mar 31, 2025
@BenediktMaag
Copy link

Since this PEP contains packages.index may i propose to add functionality for uv add (--script) for the lockfile to solve #11053

@charliermarsh
Copy link
Member Author

Yes, exporting to PEP 751 would solve that issue.

@gaborbernat
Copy link
Contributor

The biggest limitation is that there's no support for arbitrary entrypoints to the graph, because pylock.toml includes a fixed marker for each package entry rather than recording a graph of dependencies.

Any insight why this limitation was deemed out of the scope for that PEP?

@charliermarsh
Copy link
Member Author

Yeah, it was discussed at length but it was ultimately decided that it was adding too much complexity for a first draft / version of the spec. uv is also the only tool that supports this IIUC which made it hard to motivate standardizing around it right now.

@gaborbernat
Copy link
Contributor

Is there an effort to work on a version 2 that would add support for it?😅

Do you have some plans on how to select when both lock files are present or what would UV lock generate by default? In the long term obviously, as this ticket says that we'll only support it via export.

@charliermarsh
Copy link
Member Author

There isn't yet, but there should be eventually. It was made fairly clear in the DPO discussion that if there is a Version 2 with support for these kinds of features, the expectation is that the PEP would need to be authored and driven by tooling authors (uv, Poetry, PDM, etc.).

@polothy
Copy link

polothy commented Apr 4, 2025

Supporting pylock.toml as a dependency source for uv pip install, or maybe just uv pip sync?

Please support uv pip install to support the Lambda zip bundling workflow. Thanks!

@benwebber
Copy link

We use uv pip compile to compile requirements.txt files instead of using uv lock files. Will it be possible to compile pylock.toml files directly from pyproject.toml, without generating a uv lock file and exporting it?

@charliermarsh
Copy link
Member Author

Yeah I think so. I expect uv pip compile and uv export to both support it as an output format.

@Gankra Gankra changed the title Add support for PEP 751 Add support for PEP 751 lockfiles Apr 11, 2025
@charliermarsh
Copy link
Member Author

The initial uv export support is here: #12955

@charliermarsh
Copy link
Member Author

uv export, uv pip compile, uv pip sync, and uv pip install will support pylock.toml in the next release:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

6 participants