From 8814da4791b1e6e19650c097f509244c86d0bad4 Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 4 Sep 2024 12:39:58 +0200 Subject: [PATCH] Introduce uv-production-flate2-backend for automatic rust_backend usage on s390x and zlib-ng everywhere else (but only in production) --- .github/workflows/build-binaries.yml | 2 +- Cargo.lock | 8 ++++++++ Cargo.toml | 3 ++- .../uv-production-flate2-backend/Cargo.toml | 19 +++++++++++++++++++ .../uv-production-flate2-backend/src/lib.rs | 3 +++ crates/uv/Cargo.toml | 9 ++++++--- 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 crates/uv-production-flate2-backend/Cargo.toml create mode 100644 crates/uv-production-flate2-backend/src/lib.rs diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 269d418a3550..f019890fac19 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -378,7 +378,7 @@ jobs: target: ${{ matrix.platform.target }} manylinux: auto docker-options: ${{ matrix.platform.maturin_docker_options }} - args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features production + args: --release --locked --out dist --no-default-features --features production - uses: uraimo/run-on-arch-action@v2 if: matrix.platform.arch != 'ppc64' name: Test wheel diff --git a/Cargo.lock b/Cargo.lock index a7de2f2eb11a..0d1dbbb87116 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4502,6 +4502,7 @@ dependencies = [ "uv-git", "uv-installer", "uv-normalize", + "uv-production-flate2-backend", "uv-production-memory-allocator", "uv-python", "uv-requirements", @@ -4935,6 +4936,13 @@ dependencies = [ "serde", ] +[[package]] +name = "uv-production-flate2-backend" +version = "0.1.0" +dependencies = [ + "flate2", +] + [[package]] name = "uv-production-memory-allocator" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index e730bdcb648e..bc01dd938e5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,7 @@ uv-virtualenv = { path = "crates/uv-virtualenv" } uv-warnings = { path = "crates/uv-warnings" } uv-workspace = { path = "crates/uv-workspace" } uv-production-memory-allocator = { path = "crates/uv-production-memory-allocator" } +uv-production-flate2-backend = { path = "crates/uv-production-flate2-backend" } anstream = { version = "0.6.13" } anyhow = { version = "1.0.80" } @@ -168,7 +169,7 @@ xz2 = { version = "0.1.7" } zip = { version = "0.6.6", default-features = false, features = ["deflate"] } [workspace.metadata.cargo-shear] -ignored = ["flate2", "xz2", "uv-production-memory-allocator"] +ignored = ["flate2", "xz2", "uv-production-memory-allocator", "uv-production-flate2-backend"] [patch.crates-io] # For pyproject-toml diff --git a/crates/uv-production-flate2-backend/Cargo.toml b/crates/uv-production-flate2-backend/Cargo.toml new file mode 100644 index 000000000000..a094763c6183 --- /dev/null +++ b/crates/uv-production-flate2-backend/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "uv-production-flate2-backend" +version = "0.1.0" +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +documentation.workspace = true +repository.workspace = true +authors.workspace = true +license.workspace = true + +[target.'cfg(not(target_arch = "s390x"))'.dependencies] +flate2 = { version = "1.0.28", default-features = false, features = ["zlib-ng"] } + +[target.'cfg(target_arch = "s390x")'.dependencies] +flate2 = { version = "1.0.28", default-features = false, features = ["rust_backend"] } + +[lints] +workspace = true diff --git a/crates/uv-production-flate2-backend/src/lib.rs b/crates/uv-production-flate2-backend/src/lib.rs new file mode 100644 index 000000000000..47630c6d1642 --- /dev/null +++ b/crates/uv-production-flate2-backend/src/lib.rs @@ -0,0 +1,3 @@ +//! The sole purpose of this crate is to enable one of +//! `flate2/zlib-ng` (on most platforms) or `flate2/rust_backend` +//! (on s390x) diff --git a/crates/uv/Cargo.toml b/crates/uv/Cargo.toml index cdf79275a54f..83dcc34d07f6 100644 --- a/crates/uv/Cargo.toml +++ b/crates/uv/Cargo.toml @@ -44,6 +44,7 @@ uv-virtualenv = { workspace = true } uv-warnings = { workspace = true } uv-workspace = { workspace = true } uv-production-memory-allocator = { workspace = true, optional = true } +uv-production-flate2-backend = { workspace = true, optional = true } anstream = { workspace = true } anyhow = { workspace = true } @@ -94,13 +95,15 @@ tempfile = { workspace = true } zip = { workspace = true } [package.metadata.cargo-shear] -ignored = ["flate2", "uv-production-memory-allocator"] +ignored = ["flate2", "uv-production-memory-allocator", "uv-production-flate2-backend"] [features] -default = ["flate2/zlib-ng", "python", "pypi", "git"] +default = ["python", "pypi", "git"] # Use better memory allocators, etc. — also turns-on self-update. -production = ["self-update", "production-memory-allocator", "uv-distribution/production"] +production = ["self-update", "production-memory-allocator", "production-flate2-backend", "uv-distribution/production"] production-memory-allocator = ["dep:uv-production-memory-allocator"] +production-flate2-backend = ["dep:uv-production-flate2-backend"] + # Introduces a dependency on a local Python installation. python = [] # Introduces a dependency on a local Python installation with specific patch versions.