Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Follow up to #15563
Closes #13485
This is a first-pass at adding support for conditional support for Git LFS between git sources, initial feedback welcome.
e.g.
For context previously a user had to set
UV_GIT_LFS
to have uv fetch lfs objects on git sources. This env var was all or nothing, meaning you must always have it set to get consistent behavior and it applied to all git sources. If you fetched lfs objects at a revision and then turned off lfs (or vice versa), the git db, corresponding checkout lfs artifacts would not be updated properly. Similarly, when git source distributions were built, there would be no distinction between sources with lfs and without lfs. Hence, it could corrupt the git, sdist, and archive caches.In order to support some sources being LFS enabled and other not, this PR adds a stateful layer roughly similar to how
subdirectory
works but forlfs
since the git database, the checkouts and the corresponding caching layers needed to be LFS aware (requested vs installed). The caches also had to isolated and treated entirely separate when handling LFS sources.Summary
lfs = true
orlfs = false
(default) to git sources in pyproject.tomllfs=true
query param / fragments to most relevant url structs--lfs
is supported insteaddirect-url.json
now has an customgit_lfs
entry under VcsInfo (note, this is not in the spec currently -- see caveats)._lfs
suffix identity as the sources should be treated effectively different for the same rev.Caveats
pylock.toml
import support has not been added via lfs=true, going through the spec it wasn't clear to me it's something we'd support outside of the env var (for now).git_lfs
field under VcsInfo which may be undersirable although the PEP 610 does sayAdditional fields that would be necessary to support such VCS SHOULD be prefixed with the VCS command name
which could be interpret this change as ok.UV_GIT_LFS
as all git lockfile entries will get a lfs=true fragment. The cache version does not need an update, but LFS sources will get their own namespace under git-v0 and sdist-v9/git hence a cache-miss will occur once.Test Plan
Some initial tests were added. More tests likely to follow as we reach consensus on a final approach. Some existing tests still need to be updated.
For IT test, a repo under astral with LFS enabled would be great. I can keep using the one from @zanieb, but we'll want more LFS commits to test changing commits with different LFS artifacts.
Manual testing was done for common pathological cases like killing LFS fetch mid-way, uninstalling LFS after installing an sdist with it and reinstalling, fetching LFS artifacts in different commits, etc.