You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caveat: this is certainly not a complete proposal, and I reckon I have not investigated the capabilities of uv lock/sync in any detail, so consider this as thoughts to start the conversation on the usefulness of such features.
What
The uv.lock format supports locking source distributions (from sdists, git source trees, ...). This is great!
I would find it useful that
commands that install from a lock file fail (by default?) if they need to install build dependencies that are not locked
the lock command grows a mean to lock the build system requirements of the source dependencies declared in the lock file it produces
Why
When installing from a lock file I expect that everything that the installation downloads (or obtains from cache) is checked against the hashes (or immutable VCS commit hashes) that are present in the lock file, for repeatability and security.
If, during installation, other artifacts are downloaded (or obtained from cache) without my knowledge (to build source distributions), the security and repeatability of the process is weakened.
some build dependencies are dynamic (get_requires_for_build_{wheel,editable}), further complicating the locking operation
different locked source distributions may require different versions of the same build dependency
a first valuable step could be to lock build dependencies for which no wheel is available, and warn when an artifact that is not locked is downloaded when syncing
Reacted by Pavel Logan Dikov, Devid, T-256, Vlad Ivanov, Ed Morley, Alexander Holmbäck, Ibrahim Fuad, Callum McMahon, adisbladis, Jairo Llopis and 48 more
I was going to raise this same issue as well. Currently build-system.requires is completely unconstrained/unconstrainable and this is causing problems with build reproducibility.
This is causing real-life inconveniences in our organisation as, for example, new versions of setuptools appear but are not yet given the all-clear by our scanning suite. Versions that are not cleared yield a HTTP 403 upon download. The end result is a de-facto intractable state where no one can build (or even editably install) packages. (unless the developer decides to hard-constrain @ pyproject.toml, which is terrible UX and also doesn't help with the dependency-on-sdist problem.)
(I will probably also raise a separate issue w.r.t the handling of 403 codes -- this is a pain point with pip and it would be awesome if uv could do better)
I really want to do this (lock the build requirements).
Reacted by Stéphane Bidoul, Damian Shaw, Alexander Holmbäck, Mirko Lenz, czechnology, Robert Sliwinski, Edgar Ramírez Mondragón, Stuart Horner, Anders Kaseorg, Rob Moore and 12 more
Hmm but that's more about lockfiles in general, not specific to build-time deps?
Correct me if I'm wrong but to me this PEP looks to be in early stages, and uv.lock looks way more mature as it is now. I would expect the introduction of this PEP to be orthogonal to the goal of being able to lock build dependencies - in the end if uv does decide to adopt the format, the build dependency group will probably be locked in a similar way to other dependency groups regardless of the final lock file format
@notatallshaw -- No, I agree with you, it's just that: if we add support for it here, what happens if PEP 751 comes out and we can't translate that support to the PEP?
Could you use the space for tool specific data in the PEP 751 lock file? Or even using one of the main fields like groups using some kind of convention that makes it possible for locked build deps to co-exist with other named things stored there.
what happens if PEP 751 comes out and we can't translate that support to the PEP?
I mean, this wouldn't be the first feature that uv supports that vanilla python tooling doesn't. This is important enough to implement regardless of what python itself does; after all, even locking of regular dependencies is not really supported out of the box, doesn't mean that uv should be restricted by that
Since PEP 751 is now accepted, and the resulting lock file isn't immediately usable for uv as a project lock file, perhaps it makes sense to add this as a uv.lock feature.
Reacted by Heiner, purepani, Edgar Ramírez Mondragón, Kai Norman Clasen, Rob Moore, Robin Lambertz, Alex Gaynor, Phani Rithvij, Matei Dibu, George Kontridze and 23 more
Build contraints help but they'd need to be managed manually, won't work if there are conflicting build constraints in the project, and it's easy to forget a build constraint, which you only realize months or years later when a build fails.
Building with --require-hashes seems to be a decent check for a forgotten build constraint. With
❯ uv --version
uv 0.8.5
I get, when I use --build-constraints=./requirements.txt --no-binary=:all:
❯ uv pip install --strict --no-deps --no-cache --no-config --no-progress --require-hashes --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt --no-binary=:all:
Using Python 3.12.11 environment at: pepa
Resolved 71 packages in 268ms
Building nbclient==0.10.2
Building ptyprocess==0.7.0
Building typing-extensions==4.14.1
Building jupyter-core==5.7.2
Building tinycss2==1.4.0
× Failed to download and build `nbclient==0.10.2`
├─▶ Failed to resolve requirements from `build-system.requires`
├─▶ No solution found when resolving: `hatchling>=1.10.0`
╰─▶ In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `hatchling`
The above is actually a great inconvenience to me, but I see some may benefit from this behavior.
I'm having a Chief Architect asking me questions because we could not pin our transitive build-dependencies and meson 1.11 release yesterday broke the pandas 2.3 build
looks like this is now supported with build-constraint-dependencies, but i can't seem to figure out how to actually generate those hashes like you can with uv lock. seems like you need to manually determine the hashes for each build dependency, or am i missing something?
It's "supported" in the sense that you can manually achieve locking behavior, but yes, you need to enumerate the hashes by hand (which we're just doing with an agent) — it's an interim solution at best. We're still interested in building this as a first-class feature, it's just hard :)
Reacted by DetachHead, Pierre Verkest and Todd Leonhardt
Activity
paveldikov commentedon Jul 21, 2024
I was going to raise this same issue as well. Currently
build-system.requiresis completely unconstrained/unconstrainable and this is causing problems with build reproducibility.This is causing real-life inconveniences in our organisation as, for example, new versions of
setuptoolsappear but are not yet given the all-clear by our scanning suite. Versions that are not cleared yield a HTTP 403 upon download. The end result is a de-facto intractable state where no one can build (or even editably install) packages. (unless the developer decides to hard-constrain @pyproject.toml, which is terrible UX and also doesn't help with the dependency-on-sdist problem.)(I will probably also raise a separate issue w.r.t the handling of 403 codes -- this is a pain point with
pipand it would be awesome ifuvcould do better)charliermarsh commentedon Jul 28, 2024
Definitely agree that we should do this.
charliermarsh commentedon Sep 10, 2024
I really want to do this (lock the build requirements).
build: Implement pip fallback behaviour as default for sdist builds
build: Implement pip fallback behaviour as default for sdist builds
vlad-ivanov-name commentedon Nov 15, 2024
This is becoming more relevant with newer python versions that don't ship setuptools by default anymore
charliermarsh commentedon Nov 15, 2024
I really want to do this and would like to spend time on it personally, but I'm worried about how it will intersect with PEP 751.
vlad-ivanov-name commentedon Nov 15, 2024
Hmm but that's more about lockfiles in general, not specific to build-time deps?
Correct me if I'm wrong but to me this PEP looks to be in early stages, and uv.lock looks way more mature as it is now. I would expect the introduction of this PEP to be orthogonal to the goal of being able to lock build dependencies - in the end if uv does decide to adopt the format, the build dependency group will probably be locked in a similar way to other dependency groups regardless of the final lock file format
notatallshaw commentedon Nov 15, 2024
Last I saw build time dependencies were dropped from PEP 751: https://discuss.python.org/t/pep-751-lock-files-again/59173/222 (end of that post).
I don't think anything changed: https://peps.python.org/pep-0751/#locking-build-requirements-for-sdists (FYI I really hope the "it confused enough people " isn't directed at me, I had some clarifying questions, and was mostly happy with the answers).
charliermarsh commentedon Nov 15, 2024
@notatallshaw -- No, I agree with you, it's just that: if we add support for it here, what happens if PEP 751 comes out and we can't translate that support to the PEP?
bluss commentedon Nov 15, 2024
Could you use the space for tool specific data in the PEP 751 lock file? Or even using one of the main fields like
groupsusing some kind of convention that makes it possible for locked build deps to co-exist with other named things stored there.notatallshaw commentedon Nov 15, 2024
Yeah, makes sense to see the finalized version of PEP 751 first.
vlad-ivanov-name commentedon Nov 16, 2024
I mean, this wouldn't be the first feature that uv supports that vanilla python tooling doesn't. This is important enough to implement regardless of what python itself does; after all, even locking of regular dependencies is not really supported out of the box, doesn't mean that uv should be restricted by that
dimbleby commentedon Nov 19, 2024
similar proposals in poetry, pdm: python-poetry/poetry#8261 (and several duplicates), pdm-project/pdm#2465
I mostly think that people who care about reproducible builds would be better served by avoiding sdists altogether with
--only-binaryor similar.2 remaining items
purepani commentedon Apr 1, 2025
Since PEP 751 is now accepted, and the resulting lock file isn't immediately usable for
uvas a project lock file, perhaps it makes sense to add this as auv.lockfeature.charliermarsh commentedon Apr 1, 2025
We're hoping to start working on this soon.
uv pip compile,uv lock) #7052 as a duplicate of this issueuv pip compileto be able to generate a build constraints file #13798 as a duplicate of this issuejiridanek commentedon Aug 6, 2025
Building with
--require-hashesseems to be a decent check for a forgotten build constraint. WithI get, when I use
--build-constraints=./requirements.txt --no-binary=:all:The above is actually a great inconvenience to me, but I see some may benefit from this behavior.
bruno-fs commentedon Aug 8, 2025
I find it a bit sad that new "universal lockfile format" from PEP 751 won't support locking build requirements for sdists, but I'm glad to hear uv is interested in solving this problem.
Install cmake as a build dependency
Modernize project for compatibility with uv (#71)
tleonhardt commentedon Mar 4, 2026
My organization needs this capability to support offline build environments.
jiridanek commentedon Apr 15, 2026
I'm having a Chief Architect asking me questions because we could not pin our transitive build-dependencies and meson 1.11 release yesterday broke the pandas 2.3 build
DetachHead commentedon Oct 14, 2026
looks like this is now supported with
build-constraint-dependencies, but i can't seem to figure out how to actually generate those hashes like you can withuv lock. seems like you need to manually determine the hashes for each build dependency, or am i missing something?zanieb commentedon Oct 14, 2026
It's "supported" in the sense that you can manually achieve locking behavior, but yes, you need to enumerate the hashes by hand (which we're just doing with an agent) — it's an interim solution at best. We're still interested in building this as a first-class feature, it's just hard :)