mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-26 18:06:45 +00:00
Add --find-links source distributions to the registry cache (#2986)
## Summary Source distributions in `--find-links` are now properly picked up in the cache. Closes https://github.com/astral-sh/uv/issues/2978.
This commit is contained in:
parent
32f129c245
commit
3dd673677a
7 changed files with 182 additions and 71 deletions
|
|
@ -87,6 +87,15 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
) -> Result<BuiltWheelMetadata, Error> {
|
||||
let built_wheel_metadata = match &source {
|
||||
BuildableSource::Dist(SourceDist::Registry(dist)) => {
|
||||
// For registry source distributions, shard by package, then version, for
|
||||
// convenience in debugging.
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Index(&dist.index)
|
||||
.wheel_dir(dist.filename.name.as_ref())
|
||||
.join(dist.filename.version.to_string()),
|
||||
);
|
||||
|
||||
let url = match &dist.file.url {
|
||||
FileLocation::RelativeUrl(base, url) => {
|
||||
pypi_types::base_url_join_relative(base, url)?
|
||||
|
|
@ -103,6 +112,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
url: &url,
|
||||
path: Cow::Borrowed(path),
|
||||
},
|
||||
&cache_shard,
|
||||
tags,
|
||||
hashes,
|
||||
)
|
||||
|
|
@ -111,15 +121,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
}
|
||||
};
|
||||
|
||||
// For registry source distributions, shard by package, then version, for
|
||||
// convenience in debugging.
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Index(&dist.index)
|
||||
.wheel_dir(dist.filename.name.as_ref())
|
||||
.join(dist.filename.version.to_string()),
|
||||
);
|
||||
|
||||
self.url(
|
||||
source,
|
||||
&dist.file.filename,
|
||||
|
|
@ -165,9 +166,19 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
.boxed()
|
||||
.await?
|
||||
} else {
|
||||
self.archive(source, &PathSourceUrl::from(dist), tags, hashes)
|
||||
.boxed()
|
||||
.await?
|
||||
let cache_shard = self
|
||||
.build_context
|
||||
.cache()
|
||||
.shard(CacheBucket::BuiltWheels, WheelCache::Path(&dist.url).root());
|
||||
self.archive(
|
||||
source,
|
||||
&PathSourceUrl::from(dist),
|
||||
&cache_shard,
|
||||
tags,
|
||||
hashes,
|
||||
)
|
||||
.boxed()
|
||||
.await?
|
||||
}
|
||||
}
|
||||
BuildableSource::Url(SourceUrl::Direct(resource)) => {
|
||||
|
|
@ -204,7 +215,13 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
.boxed()
|
||||
.await?
|
||||
} else {
|
||||
self.archive(source, resource, tags, hashes).boxed().await?
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Path(resource.url).root(),
|
||||
);
|
||||
self.archive(source, resource, &cache_shard, tags, hashes)
|
||||
.boxed()
|
||||
.await?
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -222,6 +239,14 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
) -> Result<ArchiveMetadata, Error> {
|
||||
let metadata = match &source {
|
||||
BuildableSource::Dist(SourceDist::Registry(dist)) => {
|
||||
// For registry source distributions, shard by package, then version.
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Index(&dist.index)
|
||||
.wheel_dir(dist.filename.name.as_ref())
|
||||
.join(dist.filename.version.to_string()),
|
||||
);
|
||||
|
||||
let url = match &dist.file.url {
|
||||
FileLocation::RelativeUrl(base, url) => {
|
||||
pypi_types::base_url_join_relative(base, url)?
|
||||
|
|
@ -238,6 +263,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
url: &url,
|
||||
path: Cow::Borrowed(path),
|
||||
},
|
||||
&cache_shard,
|
||||
hashes,
|
||||
)
|
||||
.boxed()
|
||||
|
|
@ -245,14 +271,6 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
}
|
||||
};
|
||||
|
||||
// For registry source distributions, shard by package, then version.
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Index(&dist.index)
|
||||
.wheel_dir(dist.filename.name.as_ref())
|
||||
.join(dist.filename.version.to_string()),
|
||||
);
|
||||
|
||||
self.url_metadata(
|
||||
source,
|
||||
&dist.file.filename,
|
||||
|
|
@ -296,7 +314,11 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
.boxed()
|
||||
.await?
|
||||
} else {
|
||||
self.archive_metadata(source, &PathSourceUrl::from(dist), hashes)
|
||||
let cache_shard = self
|
||||
.build_context
|
||||
.cache()
|
||||
.shard(CacheBucket::BuiltWheels, WheelCache::Path(&dist.url).root());
|
||||
self.archive_metadata(source, &PathSourceUrl::from(dist), &cache_shard, hashes)
|
||||
.boxed()
|
||||
.await?
|
||||
}
|
||||
|
|
@ -334,7 +356,11 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
.boxed()
|
||||
.await?
|
||||
} else {
|
||||
self.archive_metadata(source, resource, hashes)
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Path(resource.url).root(),
|
||||
);
|
||||
self.archive_metadata(source, resource, &cache_shard, hashes)
|
||||
.boxed()
|
||||
.await?
|
||||
}
|
||||
|
|
@ -573,17 +599,13 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
&self,
|
||||
source: &BuildableSource<'_>,
|
||||
resource: &PathSourceUrl<'_>,
|
||||
cache_shard: &CacheShard,
|
||||
tags: &Tags,
|
||||
hashes: HashPolicy<'_>,
|
||||
) -> Result<BuiltWheelMetadata, Error> {
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Path(resource.url).root(),
|
||||
);
|
||||
|
||||
// Fetch the revision for the source distribution.
|
||||
let revision = self
|
||||
.archive_revision(source, resource, &cache_shard, hashes)
|
||||
.archive_revision(source, resource, cache_shard, hashes)
|
||||
.await?;
|
||||
|
||||
// Before running the build, check that the hashes match.
|
||||
|
|
@ -644,16 +666,12 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
&self,
|
||||
source: &BuildableSource<'_>,
|
||||
resource: &PathSourceUrl<'_>,
|
||||
cache_shard: &CacheShard,
|
||||
hashes: HashPolicy<'_>,
|
||||
) -> Result<ArchiveMetadata, Error> {
|
||||
let cache_shard = self.build_context.cache().shard(
|
||||
CacheBucket::BuiltWheels,
|
||||
WheelCache::Path(resource.url).root(),
|
||||
);
|
||||
|
||||
// Fetch the revision for the source distribution.
|
||||
let revision = self
|
||||
.archive_revision(source, resource, &cache_shard, hashes)
|
||||
.archive_revision(source, resource, cache_shard, hashes)
|
||||
.await?;
|
||||
|
||||
// Before running the build, check that the hashes match.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue