mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 12:24:15 +00:00
Use registry URL for fetching source distributions from lockfile (#4280)
## Summary This is just a logic bug with no testing. We were using the registry URL (like `https://pypi.org/simple`) as the URL from which a source distribution should be downloaded. Closes https://github.com/astral-sh/uv/issues/4281. ## Test Plan `cargo test`
This commit is contained in:
parent
16b4a886a8
commit
44f1afd6b0
2 changed files with 47 additions and 3 deletions
|
|
@ -732,14 +732,23 @@ impl Distribution {
|
|||
Ok(Dist::Source(source_dist))
|
||||
}
|
||||
Source::Registry(url) => {
|
||||
let file_url = sdist.url().ok_or_else(|| LockErrorKind::MissingUrl {
|
||||
id: self.id.clone(),
|
||||
})?;
|
||||
let filename =
|
||||
sdist
|
||||
.filename()
|
||||
.ok_or_else(|| LockErrorKind::MissingFilename {
|
||||
id: self.id.clone(),
|
||||
})?;
|
||||
let file = Box::new(distribution_types::File {
|
||||
dist_info_metadata: false,
|
||||
filename: sdist.filename().unwrap().to_string(),
|
||||
filename: filename.to_string(),
|
||||
hashes: vec![],
|
||||
requires_python: None,
|
||||
size: sdist.size(),
|
||||
upload_time_utc_ms: None,
|
||||
url: FileLocation::AbsoluteUrl(url.to_string()),
|
||||
url: FileLocation::AbsoluteUrl(file_url.to_string()),
|
||||
yanked: None,
|
||||
});
|
||||
let index = IndexUrl::Url(VerbatimUrl::from_url(url.clone()));
|
||||
|
|
@ -1196,7 +1205,7 @@ where
|
|||
}
|
||||
|
||||
impl SourceDist {
|
||||
pub(crate) fn filename(&self) -> Option<Cow<str>> {
|
||||
fn filename(&self) -> Option<Cow<str>> {
|
||||
match self {
|
||||
SourceDist::Url { url, .. } => url.filename().ok(),
|
||||
SourceDist::Path { path, .. } => {
|
||||
|
|
@ -1205,6 +1214,13 @@ impl SourceDist {
|
|||
}
|
||||
}
|
||||
|
||||
fn url(&self) -> Option<&Url> {
|
||||
match &self {
|
||||
SourceDist::Url { url, .. } => Some(url),
|
||||
SourceDist::Path { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn hash(&self) -> Option<&Hash> {
|
||||
match &self {
|
||||
SourceDist::Url { metadata, .. } => metadata.hash.as_ref(),
|
||||
|
|
@ -1857,6 +1873,20 @@ enum LockErrorKind {
|
|||
/// The kind of the invalid source.
|
||||
source_type: &'static str,
|
||||
},
|
||||
/// An error that occurs when a distribution indicates that it is sourced from a registry, but
|
||||
/// is missing a URL.
|
||||
#[error("found registry distribution {id} without a valid URL")]
|
||||
MissingUrl {
|
||||
/// The ID of the distribution that is missing a URL.
|
||||
id: DistributionId,
|
||||
},
|
||||
/// An error that occurs when a distribution indicates that it is sourced from a registry, but
|
||||
/// is missing a filename.
|
||||
#[error("found registry distribution {id} without a valid filename")]
|
||||
MissingFilename {
|
||||
/// The ID of the distribution that is missing a filename.
|
||||
id: DistributionId,
|
||||
},
|
||||
/// An error that occurs when a distribution is included with neither wheels nor a source
|
||||
/// distribution.
|
||||
#[error("found distribution {id} with neither wheels nor source distribution")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue