Skip to content

Commit 2e62ee4

Browse files
committed
Re-add both tar backends
Signed-off-by: William Woodruff <william@yossarian.net>
1 parent 330759b commit 2e62ee4

19 files changed

Lines changed: 691 additions & 158 deletions

File tree

Cargo.lock

Lines changed: 63 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ anstream = { version = "1.0.0" }
9999
anyhow = { version = "1.0.89" }
100100
arcstr = { version = "1.2.0" }
101101
arrayvec = { version = "0.7.6" }
102+
astral-tokio-tar = { version = "0.6.3" }
102103
async-channel = { version = "2.3.1" }
103104
async-compression = { version = "0.4.12", features = [
104105
"bzip2",

crates/uv-bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ uv-pep440 = { workspace = true }
4242
uv-pep508 = { workspace = true }
4343
uv-performance-memory-allocator = { workspace = true }
4444
uv-platform-tags = { workspace = true }
45-
uv-preview = { workspace = true }
45+
uv-preview = { workspace = true, features = ["testing"] }
4646
uv-pypi-types = { workspace = true }
4747
uv-python = { workspace = true }
4848
uv-resolver = { workspace = true }

crates/uv-bench/benches/uv.rs

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use uv_client::{BaseClientBuilder, Connectivity, RegistryClientBuilder};
2020
use uv_distribution_filename::{SourceDistExtension, WheelFilename};
2121
use uv_distribution_types::Requirement;
2222
use uv_install_wheel::{InstallState, Layout, LinkMode};
23-
use uv_preview::Preview;
23+
use uv_preview::{Preview, PreviewFeature};
2424
use uv_pypi_types::Scheme;
2525
use uv_python::PythonEnvironment;
2626
use uv_resolver::Manifest;
@@ -108,32 +108,41 @@ fn unpack_sdist_many_files(c: &mut Criterion<WallTime>) {
108108
.build()
109109
.expect("Failed to create Tokio runtime");
110110

111-
c.bench_function("unpack_sdist_many_files", |b| {
112-
b.iter_batched(
113-
|| {
114-
(
115-
runtime
116-
.block_on(fs_err::tokio::File::open(archive.path()))
117-
.expect("Failed to open temporary archive"),
118-
create_sdist_extraction_directory(),
119-
)
120-
},
121-
|(archive, extracted_sdist)| {
122-
let files = runtime
123-
.block_on(uv_extract::stream::archive(
124-
MANY_FILES_SDIST_FILENAME,
125-
archive,
126-
SourceDistExtension::TarGz,
127-
extracted_sdist.path(),
128-
))
129-
.expect("Failed to unpack sdist");
130-
let source_tree = uv_extract::strip_component(extracted_sdist.path())
131-
.expect("Failed to strip top-level sdist directory");
132-
black_box((files, extracted_sdist, source_tree))
133-
},
134-
BatchSize::PerIteration,
135-
);
136-
});
111+
for (name, preview_features) in [
112+
("unpack_sdist_many_files/astral_tokio_tar", &[][..]),
113+
(
114+
"unpack_sdist_many_files/tar_codec",
115+
&[PreviewFeature::TarCodec][..],
116+
),
117+
] {
118+
let _preview = uv_preview::test::with_features(preview_features);
119+
c.bench_function(name, |b| {
120+
b.iter_batched(
121+
|| {
122+
(
123+
runtime
124+
.block_on(fs_err::tokio::File::open(archive.path()))
125+
.expect("Failed to open temporary archive"),
126+
create_sdist_extraction_directory(),
127+
)
128+
},
129+
|(archive, extracted_sdist)| {
130+
let files = runtime
131+
.block_on(uv_extract::stream::archive(
132+
MANY_FILES_SDIST_FILENAME,
133+
archive,
134+
SourceDistExtension::TarGz,
135+
extracted_sdist.path(),
136+
))
137+
.expect("Failed to unpack sdist");
138+
let source_tree = uv_extract::strip_component(extracted_sdist.path())
139+
.expect("Failed to strip top-level sdist directory");
140+
black_box((files, extracted_sdist, source_tree))
141+
},
142+
BatchSize::PerIteration,
143+
);
144+
});
145+
}
137146
}
138147

139148
fn unzip_wheel_many_files(c: &mut Criterion<WallTime>) {

crates/uv-build-backend/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ uv-version = { workspace = true }
2929
uv-toml = { workspace = true }
3030
uv-warnings = { workspace = true }
3131

32+
astral-tokio-tar = { workspace = true }
3233
async_zip = { workspace = true }
3334
base64 = { workspace = true }
3435
csv = { workspace = true }

crates/uv-build-backend/src/lib.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ pub enum Error {
8484
#[error("Inconsistent metadata between prepare and build step: {0}")]
8585
InconsistentSteps(&'static str),
8686
#[error("Failed to write tar archive to {}", _0.user_display())]
87-
TarWrite(
87+
TarWrite(PathBuf, #[source] io::Error),
88+
#[error("Failed to write tar archive to {}", _0.user_display())]
89+
TarCodecWrite(
8890
PathBuf,
8991
#[source] tar_codec::BuildError<tar_codec::EncodeError>,
9092
),
@@ -710,7 +712,25 @@ mod tests {
710712
/// platform-independent deterministic builds.
711713
#[test]
712714
fn built_by_uv_building() {
713-
let _preview = uv_preview::test::with_features(&[]);
715+
built_by_uv_building_with_backend(
716+
&[],
717+
"8bed1f7a8059064bcbeedb61a867cca7f63a474306011d0114280de631ac705e",
718+
);
719+
}
720+
721+
#[test]
722+
fn built_by_uv_building_tar_codec() {
723+
built_by_uv_building_with_backend(
724+
&[PreviewFeature::TarCodec],
725+
"8cb4da783db5873762b0640f83e8d14e317e6bb4edb8934936f8a4ee0d946098",
726+
);
727+
}
728+
729+
fn built_by_uv_building_with_backend(
730+
preview_features: &[PreviewFeature],
731+
expected_source_dist_hash: &str,
732+
) {
733+
let _preview = uv_preview::test::with_features(preview_features);
714734
let built_by_uv = Path::new("../../test/packages/built-by-uv");
715735
let src = TempDir::new().unwrap();
716736
for dir in [
@@ -781,9 +801,12 @@ mod tests {
781801
"built_by_uv-0.1.0.tar.gz"
782802
);
783803
// Check that the source dist is reproducible across platforms.
784-
assert_snapshot!(
785-
format!("{:x}", sha2::Sha256::digest(fs_err::read(&source_dist_path).unwrap())),
786-
@"8cb4da783db5873762b0640f83e8d14e317e6bb4edb8934936f8a4ee0d946098"
804+
assert_eq!(
805+
format!(
806+
"{:x}",
807+
sha2::Sha256::digest(fs_err::read(&source_dist_path).unwrap())
808+
),
809+
expected_source_dist_hash
787810
);
788811
// Check both the files we report and the actual files
789812
assert_snapshot!(format_file_list(build.source_dist_list_files, src.path()), @"

0 commit comments

Comments
 (0)