mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Allow non-nested archives for hexdump
and others (#1564)
## Summary#1562
It turns out that `hexdump` uses an invalid source distribution format
whereby the contents aren't nested in a top-level directory -- instead,
they're all just flattened at the top-level. In looking at pip's source
(51de88ca64/src/pip/_internal/utils/unpacking.py (L62)
),
it only strips the top-level directory if all entries have the same
directory prefix (i.e., if it's the only thing in the directory). This
PR accommodates these "invalid" distributions.
I can't find any history on this method in `pip`. It looks like it dates
back over 15 years ago, to before `pip` was even called `pip`.
Closes https://github.com/astral-sh/uv/issues/1376.
This commit is contained in:
parent
4a09889c80
commit
340cb67a8b
4 changed files with 26 additions and 13 deletions
|
@ -226,7 +226,7 @@ impl Pep517Backend {
|
|||
import sys
|
||||
sys.path = [{backend_path}] + sys.path
|
||||
|
||||
{import}
|
||||
{import}
|
||||
"#, backend_path = backend_path_encoded}
|
||||
}
|
||||
}
|
||||
|
@ -305,8 +305,11 @@ impl SourceBuild {
|
|||
.map_err(|err| Error::Extraction(extracted.clone(), err))?;
|
||||
|
||||
// Extract the top-level directory from the archive.
|
||||
uv_extract::strip_component(&extracted)
|
||||
.map_err(|err| Error::Extraction(extracted.clone(), err))?
|
||||
match uv_extract::strip_component(&extracted) {
|
||||
Ok(top_level) => top_level,
|
||||
Err(uv_extract::Error::NonSingularArchive(_)) => extracted,
|
||||
Err(err) => return Err(Error::Extraction(extracted.clone(), err)),
|
||||
}
|
||||
};
|
||||
let source_tree = if let Some(subdir) = subdirectory {
|
||||
source_root.join(subdir)
|
||||
|
@ -614,7 +617,7 @@ impl SourceBuild {
|
|||
let script = formatdoc! {
|
||||
r#"{}
|
||||
print(backend.build_{}("{}", metadata_directory={}))
|
||||
"#, pep517_backend.backend_import(), self.build_kind, escaped_wheel_dir, metadata_directory
|
||||
"#, pep517_backend.backend_import(), self.build_kind, escaped_wheel_dir, metadata_directory
|
||||
};
|
||||
let span = info_span!(
|
||||
"run_python_script",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue