uv-resolver: add initial version of universal lock file format#3314
Merged
BurntSushi merged 4 commits intomainfrom Apr 29, 2024
Merged
uv-resolver: add initial version of universal lock file format#3314BurntSushi merged 4 commits intomainfrom
BurntSushi merged 4 commits intomainfrom
Conversation
52cc45a to
b538042
Compare
konstin
approved these changes
Apr 29, 2024
Comment on lines
+222
to
+223
| // FIXME: Fill in the git revision details here. They aren't in | ||
| // `GitSourceDist`, so this will likely need some refactoring. |
Member
There was a problem hiding this comment.
I also ran into this problem a bunch; we're tracking some information on the urls of the dist types but it's not readily accessible
This is useful when one wants a `url::Url` from a `FileLocation`. I believe we primarily represent `FileLocation` as strings for performance/serialization reasons, but when generating a lock, we'd really just like to normalize everything to a URL. In some cases, a `FileLocation` is generated from a known-valid `url::Url`, and so that the conversion back to a `url::Url` *should* be infallible. But this is not, I believe, guaranteed in all cases.
This is meant to be a base on which to build. There are some parts which are implicitly incomplete and others which are explicitly incomplete. The latter are indicated by TODO comments. Here is a non-exhaustive list of incomplete things. In many cases, these are incomplete simply because the data isn't present in a `ResolutionGraph`. Future work will need to refactor our resolver so that this data is correctly passed down. * Not all wheels are included. Only the "selected" wheel for the current distribution is included. * Marker expressions are always absent. * We don't emit hashes for certainly kinds of distributions (direct URLs, git, and path). * We don't capture git information from a dependency specification. Right now, we just always emit "default branch." There are perhaps also other changes we might want to make to the format of a more cosmetic nature. Right now, all arrays are encoded using whatever the `toml` crate decides to do. But we might want to exert more control over this. For example, by using inline tables or squashing more things into strings (like I did for `Source` and `Hash`). I think the main trade-off here is that table arrays are somewhat difficult to read (especially without indentation), where as squashing things down into a more condensed format potentially makes future compatible additions harder.
This does a simple traversal of our resolution graph to generated a list of distributions (and their dependencies) as a `Lock`.
This flag is hidden, and it is not meant to live forever. Its only purpose is to provide a way to generate a `uv.lock` using our existing CLI tooling. We specifically avoid adding this to persistent configuration to minimize where it can be used.
b538042 to
24813a4
Compare
This was referenced Apr 29, 2024
ibraheemdev
added a commit
that referenced
this pull request
Apr 29, 2024
## Summary Makes the `serde` implementations added in #3314 conditional on uv-resolver's `serde` feature.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is meant to be a base on which to build. There are some parts
which are implicitly incomplete and others which are explicitly
incomplete. The latter are indicated by TODO comments.
Here is a non-exhaustive list of incomplete things. In many cases, these
are incomplete simply because the data isn't present in a
ResolutionGraph. Future work will need to refactor our resolver sothat this data is correctly passed down.
distribution is included.
URLs, git, and path).
Right now, we just always emit "default branch."
There are perhaps also other changes we might want to make to the format
of a more cosmetic nature. Right now, all arrays are encoded using
whatever the
tomlcrate decides to do. But we might want to exert morecontrol over this. For example, by using inline tables or squashing more
things into strings (like I did for
SourceandHash). I think themain trade-off here is that table arrays are somewhat difficult to read
(especially without indentation), where as squashing things down into a
more condensed format potentially makes future compatible additions
harder.
I also went pretty light on the documentation here than what I would
normally do. That's primarily because I think this code is going to
go through some evolution and I didn't want to spend too much time
documenting something that is likely to change.
Finally, here's an example of the lock file format in TOML for the
anyiodependency. I generated it with the following command:And that writes out a
uv.lockfile: