mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-27 02:17:08 +00:00
Return computed hashes from metadata requests (#2951)
## Summary This PR modifies the distribution database to return both the `Metadata23` and the computed hashes when clients request metadata. No behavior changes, but this will be necessary to power `--generate-hashes`.
This commit is contained in:
parent
c18551fd3c
commit
8513d603b4
9 changed files with 100 additions and 60 deletions
|
|
@ -100,30 +100,30 @@ impl<'a, Context: BuildContext + Send + Sync> SourceTreeResolver<'a, Context> {
|
|||
// Fetch the metadata for the distribution.
|
||||
let metadata = {
|
||||
let id = PackageId::from_url(source.url());
|
||||
if let Some(metadata) = self
|
||||
if let Some(archive) = self
|
||||
.index
|
||||
.get_metadata(&id)
|
||||
.as_deref()
|
||||
.and_then(|response| {
|
||||
if let MetadataResponse::Found(metadata) = response {
|
||||
Some(metadata)
|
||||
if let MetadataResponse::Found(archive) = response {
|
||||
Some(archive)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
{
|
||||
// If the metadata is already in the index, return it.
|
||||
metadata.clone()
|
||||
archive.metadata.clone()
|
||||
} else {
|
||||
// Run the PEP 517 build process to extract metadata from the source distribution.
|
||||
let source = BuildableSource::Url(source);
|
||||
let metadata = self.database.build_wheel_metadata(&source, &[]).await?;
|
||||
let archive = self.database.build_wheel_metadata(&source, &[]).await?;
|
||||
|
||||
// Insert the metadata into the index.
|
||||
self.index
|
||||
.insert_metadata(id, MetadataResponse::Found(metadata.clone()));
|
||||
.insert_metadata(id, MetadataResponse::Found(archive.clone()));
|
||||
|
||||
metadata
|
||||
archive.metadata
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue