mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Avoid inferring package name for GitHub Archives (#4928)
## Summary Closes https://github.com/astral-sh/uv/issues/4917.
This commit is contained in:
parent
0bf562f197
commit
2e307d9081
1 changed files with 27 additions and 7 deletions
|
@ -7,6 +7,7 @@ use configparser::ini::Ini;
|
||||||
use futures::{stream::FuturesOrdered, TryStreamExt};
|
use futures::{stream::FuturesOrdered, TryStreamExt};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
use url::Host;
|
||||||
|
|
||||||
use distribution_filename::{SourceDistFilename, WheelFilename};
|
use distribution_filename::{SourceDistFilename, WheelFilename};
|
||||||
use distribution_types::{
|
use distribution_types::{
|
||||||
|
@ -128,6 +129,24 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|filename| SourceDistFilename::parsed_normalized_filename(&filename).ok())
|
.and_then(|filename| SourceDistFilename::parsed_normalized_filename(&filename).ok())
|
||||||
{
|
{
|
||||||
|
// But ignore GitHub archives, like:
|
||||||
|
// https://github.com/python/mypy/archive/refs/heads/release-1.11.zip
|
||||||
|
//
|
||||||
|
// These have auto-generated filenames that will almost never match the package name.
|
||||||
|
if requirement.url.verbatim.host() == Some(Host::Domain("github.com"))
|
||||||
|
&& requirement
|
||||||
|
.url
|
||||||
|
.verbatim
|
||||||
|
.path_segments()
|
||||||
|
.is_some_and(|mut path_segments| {
|
||||||
|
path_segments.any(|segment| segment == "archive")
|
||||||
|
})
|
||||||
|
{
|
||||||
|
debug!(
|
||||||
|
"Rejecting inferred name from GitHub archive: {}",
|
||||||
|
requirement.url.verbatim
|
||||||
|
);
|
||||||
|
} else {
|
||||||
return Ok(pep508_rs::Requirement {
|
return Ok(pep508_rs::Requirement {
|
||||||
name: filename.name,
|
name: filename.name,
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
|
@ -136,6 +155,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
origin: requirement.origin,
|
origin: requirement.origin,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let source = match &requirement.url.parsed_url {
|
let source = match &requirement.url.parsed_url {
|
||||||
// If the path points to a directory, attempt to read the name from static metadata.
|
// If the path points to a directory, attempt to read the name from static metadata.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue