mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 12:59:45 +00:00
Add parsed URL fields to Dist variants (#3429)
Avoid reparsing urls by storing the parsed parts across resolution on `Dist`. Part 2 of https://github.com/astral-sh/uv/issues/3408 and part of #3409 Closes #3408
This commit is contained in:
parent
0010954ca7
commit
c22c7cad4c
8 changed files with 107 additions and 83 deletions
|
|
@ -13,6 +13,7 @@ use pep508_rs::MarkerEnvironment;
|
|||
use pypi_types::Metadata23;
|
||||
use uv_configuration::{Constraints, Overrides};
|
||||
use uv_distribution::{DistributionDatabase, Reporter};
|
||||
use uv_git::GitUrl;
|
||||
use uv_resolver::{InMemoryIndex, MetadataResponse};
|
||||
use uv_types::{BuildContext, HashStrategy, RequestedRequirements};
|
||||
|
||||
|
|
@ -162,16 +163,28 @@ impl<'a, Context: BuildContext> LookaheadResolver<'a, Context> {
|
|||
// buildable distribution.
|
||||
let dist = match requirement.source {
|
||||
RequirementSource::Registry { .. } => return Ok(None),
|
||||
RequirementSource::Url { url, .. } => Dist::from_http_url(requirement.name, url)?,
|
||||
RequirementSource::Git { url, .. } => Dist::Source(SourceDist::Git(GitSourceDist {
|
||||
RequirementSource::Url {
|
||||
subdirectory,
|
||||
location,
|
||||
url,
|
||||
} => Dist::from_http_url(requirement.name, location, subdirectory, url)?,
|
||||
RequirementSource::Git {
|
||||
repository,
|
||||
reference,
|
||||
subdirectory,
|
||||
url,
|
||||
} => Dist::Source(SourceDist::Git(GitSourceDist {
|
||||
name: requirement.name,
|
||||
git: Box::new(GitUrl::new(repository, reference)),
|
||||
subdirectory,
|
||||
url,
|
||||
})),
|
||||
RequirementSource::Path {
|
||||
path: _,
|
||||
path,
|
||||
url,
|
||||
// TODO(konsti): Figure out why we lose the editable here (does it matter?)
|
||||
editable: _,
|
||||
} => Dist::from_file_url(requirement.name, url, false)?,
|
||||
} => Dist::from_file_url(requirement.name, &path, false, url)?,
|
||||
};
|
||||
|
||||
// Fetch the metadata for the distribution.
|
||||
|
|
|
|||
|
|
@ -238,9 +238,11 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
|||
Some(Scheme::Http | Scheme::Https) => SourceUrl::Direct(DirectSourceUrl {
|
||||
url: &requirement.url,
|
||||
}),
|
||||
Some(Scheme::GitSsh | Scheme::GitHttps) => SourceUrl::Git(GitSourceUrl {
|
||||
url: &requirement.url,
|
||||
}),
|
||||
Some(Scheme::GitSsh | Scheme::GitHttps | Scheme::GitHttp) => {
|
||||
SourceUrl::Git(GitSourceUrl {
|
||||
url: &requirement.url,
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Unsupported scheme for unnamed requirement: {}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue