mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-22 12:35:36 +00:00
Pass around index with associated metadata (#12406)
## Summary This PR modifies the requirement source entities to store a (new) container struct that wraps `IndexUrl`. This will allow us to store user-defined metadata alongside `IndexUrl`, and propagate that metadata throughout resolution. Specifically, I need to store the "kind" of the index (Simple API vs. `--find-links`), but I also ran into this problem when I tried to add support for overriding `Cache-Control` headers on a per-index basis: at present, we have no way to passing around metadata alongside an `IndexUrl`.
This commit is contained in:
parent
c3442e822e
commit
1865e0a6ee
19 changed files with 213 additions and 80 deletions
|
|
@ -27,9 +27,9 @@ use uv_distribution_filename::{
|
|||
use uv_distribution_types::{
|
||||
redact_credentials, BuiltDist, DependencyMetadata, DirectUrlBuiltDist, DirectUrlSourceDist,
|
||||
DirectorySourceDist, Dist, DistributionMetadata, FileLocation, GitSourceDist, IndexLocations,
|
||||
IndexUrl, Name, PathBuiltDist, PathSourceDist, RegistryBuiltDist, RegistryBuiltWheel,
|
||||
RegistrySourceDist, RemoteSource, Requirement, RequirementSource, ResolvedDist, StaticMetadata,
|
||||
ToUrlError, UrlString,
|
||||
IndexMetadata, IndexUrl, Name, PathBuiltDist, PathSourceDist, RegistryBuiltDist,
|
||||
RegistryBuiltWheel, RegistrySourceDist, RemoteSource, Requirement, RequirementSource,
|
||||
ResolvedDist, StaticMetadata, ToUrlError, UrlString,
|
||||
};
|
||||
use uv_fs::{relative_to, PortablePath, PortablePathBuf};
|
||||
use uv_git::{RepositoryReference, ResolvedRepositoryReference};
|
||||
|
|
@ -4563,12 +4563,17 @@ fn normalize_requirement(
|
|||
}
|
||||
RequirementSource::Registry {
|
||||
specifier,
|
||||
mut index,
|
||||
index,
|
||||
conflict,
|
||||
} => {
|
||||
if let Some(index) = index.as_mut() {
|
||||
redact_credentials(index);
|
||||
}
|
||||
// Round-trip the index to remove anything apart from the URL.
|
||||
let index = index
|
||||
.map(|index| index.url.into_url())
|
||||
.map(|mut index| {
|
||||
redact_credentials(&mut index);
|
||||
index
|
||||
})
|
||||
.map(|index| IndexMetadata::from(IndexUrl::from(VerbatimUrl::from_url(index))));
|
||||
Ok(Requirement {
|
||||
name: requirement.name,
|
||||
extras: requirement.extras,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue