mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
uv-resolver: refactor Distribution::to_dist
This makes it clear that an actual `sdist` is only required when a distribution is from a registry. In all other cases, a source distribution is manufactured directly from the `source`.
This commit is contained in:
parent
840f61fc2b
commit
4899612619
1 changed files with 85 additions and 85 deletions
|
@ -686,8 +686,7 @@ impl Distribution {
|
|||
};
|
||||
}
|
||||
|
||||
if let Some(sdist) = &self.sdist {
|
||||
return match &self.id.source {
|
||||
match &self.id.source {
|
||||
Source::Path(path) => {
|
||||
let path_dist = PathSourceDist {
|
||||
name: self.id.name.clone(),
|
||||
|
@ -701,7 +700,7 @@ impl Distribution {
|
|||
lock_path: path.clone(),
|
||||
};
|
||||
let source_dist = distribution_types::SourceDist::Path(path_dist);
|
||||
Ok(Dist::Source(source_dist))
|
||||
return Ok(Dist::Source(source_dist));
|
||||
}
|
||||
Source::Directory(path) => {
|
||||
let dir_dist = DirectorySourceDist {
|
||||
|
@ -717,7 +716,7 @@ impl Distribution {
|
|||
editable: false,
|
||||
};
|
||||
let source_dist = distribution_types::SourceDist::Directory(dir_dist);
|
||||
Ok(Dist::Source(source_dist))
|
||||
return Ok(Dist::Source(source_dist));
|
||||
}
|
||||
Source::Editable(path) => {
|
||||
let dir_dist = DirectorySourceDist {
|
||||
|
@ -733,7 +732,7 @@ impl Distribution {
|
|||
editable: true,
|
||||
};
|
||||
let source_dist = distribution_types::SourceDist::Directory(dir_dist);
|
||||
Ok(Dist::Source(source_dist))
|
||||
return Ok(Dist::Source(source_dist));
|
||||
}
|
||||
Source::Git(url, git) => {
|
||||
// Reconstruct the `GitUrl` from the `GitSource`.
|
||||
|
@ -754,7 +753,7 @@ impl Distribution {
|
|||
subdirectory: git.subdirectory.as_ref().map(PathBuf::from),
|
||||
};
|
||||
let source_dist = distribution_types::SourceDist::Git(git_dist);
|
||||
Ok(Dist::Source(source_dist))
|
||||
return Ok(Dist::Source(source_dist));
|
||||
}
|
||||
Source::Direct(url, direct) => {
|
||||
let url = Url::from(ParsedArchiveUrl {
|
||||
|
@ -768,9 +767,10 @@ impl Distribution {
|
|||
url: VerbatimUrl::from_url(url),
|
||||
};
|
||||
let source_dist = distribution_types::SourceDist::DirectUrl(direct_dist);
|
||||
Ok(Dist::Source(source_dist))
|
||||
return Ok(Dist::Source(source_dist));
|
||||
}
|
||||
Source::Registry(url) => {
|
||||
if let Some(ref sdist) = self.sdist {
|
||||
let file_url = sdist.url().ok_or_else(|| LockErrorKind::MissingUrl {
|
||||
id: self.id.clone(),
|
||||
})?;
|
||||
|
@ -799,9 +799,9 @@ impl Distribution {
|
|||
wheels: vec![],
|
||||
};
|
||||
let source_dist = distribution_types::SourceDist::Registry(reg_dist);
|
||||
Ok(Dist::Source(source_dist))
|
||||
return Ok(Dist::Source(source_dist));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Err(LockErrorKind::NeitherSourceDistNorWheel {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue