Add conversion from lockfile Distribution to Metadata (#4706)

## Summary

Splitting this out from https://github.com/astral-sh/uv/pull/4495
because it's also useful to reuse the `uv pip tree` code for `uv tree`.
This commit is contained in:
Ibraheem Ahmed 2024-07-02 14:03:20 -04:00 committed by GitHub
parent 4b19319485
commit a380e8e4df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 176 additions and 28 deletions

View file

@ -253,6 +253,12 @@ impl RequirementSource {
}
}
/// Construct a [`RequirementSource`] for a URL source, given a URL parsed into components.
pub fn from_verbatim_parsed_url(parsed_url: ParsedUrl) -> Self {
let verbatim_url = VerbatimUrl::from_url(Url::from(parsed_url.clone()));
RequirementSource::from_parsed_url(parsed_url, verbatim_url)
}
/// Convert the source to a [`VerbatimParsedUrl`], if it's a URL source.
pub fn to_verbatim_parsed_url(&self) -> Option<VerbatimParsedUrl> {
match &self {