From c4a5972316f461355c9652431510daa48a0f990f Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 10:56:48 -0800 Subject: [PATCH 1/7] refactor(wheel): port wheelmaker to Rust and add it to shrubbery Port `wheelmaker` to Rust under `shrubbery` so `py_wheel` builds avoid spawning a Python interpreter when `shrubbery` is enabled. The Rust `wheelmaker` subcommand supports the `tools/wheelmaker.py` flags used by `py_wheel`, `@flagfile` parsing, PEP 427/440 normalization, workspace status stamping, and deterministic zip and `RECORD` generation. `py_wheel` selects it through `get_shrubbery_tool` and falls back to `tools/wheelmaker.py` when `shrubbery` is disabled or unavailable. In `-c opt` benchmarks against `tools/wheelmaker.py`: - Small wheels: 28x-34x faster (~6 ms vs ~183-206 ms), ~3x lower peak RSS (~7 MiB vs ~21-24 MiB) - Many files (1,000-10,000): 1.5x-4.2x faster - Uncompressed (`--no_compress`): 1.4x-33.6x faster up to 256 MiB - Compressed (DEFLATE): faster up to ~80-100 MiB at default level 6 (and across library levels 1-9 on multi-file source wheels), ~14% slower at 256 MiB (`0.86x`) once C `zlib` amortizes Python startup Work towards #4250 --- MODULE.bazel | 2 +- crates/Cargo.Bazel.lock | 4411 +++++++++++++++-- crates/Cargo.lock | 562 +++ crates/Cargo.toml | 5 + crates/shrubbery/BUILD.bazel | 1 + crates/shrubbery/src/lib.rs | 3 + crates/wheelmaker/BUILD.bazel | 28 + crates/wheelmaker/src/lib.rs | 1008 ++++ examples/wheel/BUILD.bazel | 23 +- examples/wheel/test_publish.py | 15 +- examples/wheel/wheel_test.py | 126 +- python/private/BUILD.bazel | 1 + python/private/py_wheel.bzl | 19 +- python/private/toolchains/BUILD.bazel | 5 +- .../prebuilt_toolchain/BUILD.bazel | 8 + tests/integration/prebuilt_toolchain_test.py | 17 +- tests/shrubbery/shrubbery_test.rs | 24 +- .../shrubbery_toolchain_tests.bzl | 76 +- tests/wheelmaker/BUILD.bazel | 17 + tests/wheelmaker/wheelmaker_test.rs | 1047 ++++ 20 files changed, 6928 insertions(+), 470 deletions(-) create mode 100644 crates/wheelmaker/BUILD.bazel create mode 100644 crates/wheelmaker/src/lib.rs create mode 100644 tests/wheelmaker/BUILD.bazel create mode 100644 tests/wheelmaker/wheelmaker_test.rs diff --git a/MODULE.bazel b/MODULE.bazel index b7301c7291..b30a9f5a4f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -137,7 +137,7 @@ rust_crates.from_cargo( # rules_rust has no @rules_rust//rust/platform config_setting for Linux ppc64le, # so don't mark the crates as incompatible with platforms that don't match one # of the triples above. Such platforms get only the unconditional dependencies, -# which suffice for anyhow, flate2, lexopt, sha2, and zip. +# which suffice for every crate in //crates:Cargo.toml. rust_crates.render_config( generate_target_compatible_with = False, ) diff --git a/crates/Cargo.Bazel.lock b/crates/Cargo.Bazel.lock index 4a1b392b40..203ce3fd40 100644 --- a/crates/Cargo.Bazel.lock +++ b/crates/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "269e4f7e54f04390547ffeddbf8945aa1cc32a2730cccd1792ad1ad16239b24b", + "checksum": "8e165a9ec4f3cc11a7107ce46a496182b8693e631158f49a6e6c6cfd868452e7", "crates": { "adler2 2.0.1": { "name": "adler2", @@ -41,6 +41,61 @@ ], "license_file": "LICENSE-0BSD" }, + "aho-corasick 1.1.5": { + "name": "aho-corasick", + "version": "1.1.5", + "package_url": "https://github.com/BurntSushi/aho-corasick", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/aho-corasick/1.1.5/download", + "sha256": "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" + } + }, + "targets": [ + { + "Library": { + "crate_name": "aho_corasick", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "aho_corasick", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "perf-literal", + "std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "memchr 2.8.3", + "target": "memchr" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "1.1.5" + }, + "license": "Unlicense OR MIT", + "license_ids": [ + "MIT", + "Unlicense" + ], + "license_file": "LICENSE-MIT" + }, "anyhow 1.0.104": { "name": "anyhow", "version": "1.0.104", @@ -213,6 +268,54 @@ ], "license_file": "LICENSE-APACHE" }, + "base64 0.23.1": { + "name": "base64", + "version": "0.23.1", + "package_url": "https://github.com/marshallpierce/rust-base64", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/base64/0.23.1/download", + "sha256": "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + } + }, + "targets": [ + { + "Library": { + "crate_name": "base64", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "base64", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "default", + "simd-unsafe", + "std" + ], + "selects": {} + }, + "edition": "2021", + "version": "0.23.1" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "bitflags 2.13.2": { "name": "bitflags", "version": "2.13.2", @@ -300,6 +403,44 @@ ], "license_file": "LICENSE-APACHE" }, + "boxcar 0.2.14": { + "name": "boxcar", + "version": "0.2.14", + "package_url": "https://github.com/ibraheemdev/boxcar", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/boxcar/0.2.14/download", + "sha256": "36f64beae40a84da1b4b26ff2761a5b895c12adc41dc25aaee1c4f2bbfe97a6e" + } + }, + "targets": [ + { + "Library": { + "crate_name": "boxcar", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "boxcar", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "0.2.14" + }, + "license": "MIT", + "license_ids": [ + "MIT" + ], + "license_file": "LICENSE" + }, "cfg-if 1.0.5": { "name": "cfg-if", "version": "1.0.5", @@ -616,20 +757,20 @@ ], "license_file": "LICENSE-APACHE" }, - "digest 0.11.3": { - "name": "digest", - "version": "0.11.3", - "package_url": "https://github.com/RustCrypto/traits", + "csv 1.4.0": { + "name": "csv", + "version": "1.4.0", + "package_url": "https://github.com/BurntSushi/rust-csv", "repository": { "Http": { - "url": "https://static.crates.io/crates/digest/0.11.3/download", - "sha256": "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" + "url": "https://static.crates.io/crates/csv/1.4.0/download", + "sha256": "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" } }, "targets": [ { "Library": { - "crate_name": "digest", + "crate_name": "csv", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -640,62 +781,56 @@ } } ], - "library_target_name": "digest", + "library_target_name": "csv", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { - "common": [ - "alloc", - "block-api", - "default", - "oid" - ], - "selects": {} - }, "deps": { "common": [ { - "id": "block-buffer 0.12.1", - "target": "block_buffer" + "id": "csv-core 0.1.13", + "target": "csv_core" }, { - "id": "const-oid 0.10.2", - "target": "const_oid" + "id": "itoa 1.0.19", + "target": "itoa" }, { - "id": "crypto-common 0.2.2", - "target": "crypto_common", - "alias": "common" + "id": "ryu 1.0.23", + "target": "ryu" + }, + { + "id": "serde_core 1.0.229", + "target": "serde_core" } ], "selects": {} }, - "edition": "2024", - "version": "0.11.3" + "edition": "2021", + "version": "1.4.0" }, - "license": "MIT OR Apache-2.0", + "license": "Unlicense/MIT", "license_ids": [ - "Apache-2.0", - "MIT" + "MIT", + "Unlicense" ], - "license_file": "LICENSE-APACHE" + "license_file": "LICENSE-MIT" }, - "equivalent 1.0.3": { - "name": "equivalent", - "version": "1.0.3", - "package_url": "https://github.com/indexmap-rs/equivalent", + "csv-core 0.1.13": { + "name": "csv-core", + "version": "0.1.13", + "package_url": "https://github.com/BurntSushi/rust-csv", "repository": { "Http": { - "url": "https://static.crates.io/crates/equivalent/1.0.3/download", - "sha256": "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + "url": "https://static.crates.io/crates/csv-core/0.1.13/download", + "sha256": "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" } }, "targets": [ { "Library": { - "crate_name": "equivalent", + "crate_name": "csv_core", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -706,35 +841,50 @@ } } ], - "library_target_name": "equivalent", + "library_target_name": "csv_core", "common_attrs": { "compile_data_glob": [ "**" ], - "edition": "2015", - "version": "1.0.3" + "crate_features": { + "common": [ + "default" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "memchr 2.8.3", + "target": "memchr" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.1.13" }, - "license": "Apache-2.0 OR MIT", + "license": "Unlicense/MIT", "license_ids": [ - "Apache-2.0", - "MIT" + "MIT", + "Unlicense" ], - "license_file": "LICENSE-APACHE" + "license_file": "LICENSE-MIT" }, - "flate2 1.1.11": { - "name": "flate2", - "version": "1.1.11", - "package_url": "https://github.com/rust-lang/flate2-rs", + "digest 0.11.3": { + "name": "digest", + "version": "0.11.3", + "package_url": "https://github.com/RustCrypto/traits", "repository": { "Http": { - "url": "https://static.crates.io/crates/flate2/1.1.11/download", - "sha256": "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" + "url": "https://static.crates.io/crates/digest/0.11.3/download", + "sha256": "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" } }, "targets": [ { "Library": { - "crate_name": "flate2", + "crate_name": "digest", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -745,36 +895,40 @@ } } ], - "library_target_name": "flate2", + "library_target_name": "digest", "common_attrs": { "compile_data_glob": [ "**" ], "crate_features": { "common": [ - "any_impl", + "alloc", + "block-api", "default", - "miniz_oxide", - "runtime_detection", - "rust_backend" + "oid" ], "selects": {} }, "deps": { "common": [ { - "id": "crc32fast 1.5.4", - "target": "crc32fast" + "id": "block-buffer 0.12.1", + "target": "block_buffer" }, { - "id": "miniz_oxide 0.9.1", - "target": "miniz_oxide" + "id": "const-oid 0.10.2", + "target": "const_oid" + }, + { + "id": "crypto-common 0.2.2", + "target": "crypto_common", + "alias": "common" } ], "selects": {} }, - "edition": "2018", - "version": "1.1.11" + "edition": "2024", + "version": "0.11.3" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -783,20 +937,20 @@ ], "license_file": "LICENSE-APACHE" }, - "fs-err 3.3.2": { - "name": "fs-err", - "version": "3.3.2", - "package_url": "https://github.com/andrewhickman/fs-err", + "displaydoc 0.2.7": { + "name": "displaydoc", + "version": "0.2.7", + "package_url": "https://github.com/yaahc/displaydoc", "repository": { "Http": { - "url": "https://static.crates.io/crates/fs-err/3.3.2/download", - "sha256": "b5c95b673b8f6f7235229ae11c5642d81b04c2e64c1e2fb417bc0cf73ca45f29" + "url": "https://static.crates.io/crates/displaydoc/0.2.7/download", + "sha256": "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" } }, "targets": [ { - "Library": { - "crate_name": "fs_err", + "ProcMacro": { + "crate_name": "displaydoc", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -805,53 +959,32 @@ ] } } - }, - { - "BuildScript": { - "crate_name": "build_script_build", - "crate_root": "build.rs", - "srcs": { - "allow_empty": true, - "include": [ - "**/*.rs" - ] - } - } } ], - "library_target_name": "fs_err", + "library_target_name": "displaydoc", "common_attrs": { "compile_data_glob": [ "**" ], - "extra_deps": { + "deps": { "common": [ - ":build_script_build" + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 3.0.10", + "target": "syn" + } ], "selects": {} }, - "edition": "2018", - "version": "3.3.2" - }, - "build_script_attrs": { - "compile_data_glob": [ - "**" - ], - "compile_data_glob_excludes": [ - "**/*.rs" - ], - "data_glob": [ - "**" - ], - "deps": { - "common": [ - { - "id": "autocfg 1.5.1", - "target": "autocfg" - } - ], - "selects": {} - } + "edition": "2021", + "version": "0.2.7" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -860,20 +993,20 @@ ], "license_file": "LICENSE-APACHE" }, - "hashbrown 0.17.1": { - "name": "hashbrown", - "version": "0.17.1", - "package_url": "https://github.com/rust-lang/hashbrown", + "either 1.19.0": { + "name": "either", + "version": "1.19.0", + "package_url": "https://github.com/rayon-rs/either", "repository": { "Http": { - "url": "https://static.crates.io/crates/hashbrown/0.17.1/download", - "sha256": "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + "url": "https://static.crates.io/crates/either/1.19.0/download", + "sha256": "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" } }, "targets": [ { "Library": { - "crate_name": "hashbrown", + "crate_name": "either", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -884,13 +1017,20 @@ } } ], - "library_target_name": "hashbrown", + "library_target_name": "either", "common_attrs": { "compile_data_glob": [ "**" ], - "edition": "2024", - "version": "0.17.1" + "crate_features": { + "common": [ + "std", + "use_std" + ], + "selects": {} + }, + "edition": "2021", + "version": "1.19.0" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -899,20 +1039,20 @@ ], "license_file": "LICENSE-APACHE" }, - "hybrid-array 0.4.15": { - "name": "hybrid-array", - "version": "0.4.15", - "package_url": "https://github.com/RustCrypto/hybrid-array", + "equivalent 1.0.3": { + "name": "equivalent", + "version": "1.0.3", + "package_url": "https://github.com/indexmap-rs/equivalent", "repository": { "Http": { - "url": "https://static.crates.io/crates/hybrid-array/0.4.15/download", - "sha256": "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" + "url": "https://static.crates.io/crates/equivalent/1.0.3/download", + "sha256": "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" } }, "targets": [ { "Library": { - "crate_name": "hybrid_array", + "crate_name": "equivalent", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -923,44 +1063,35 @@ } } ], - "library_target_name": "hybrid_array", + "library_target_name": "equivalent", "common_attrs": { "compile_data_glob": [ "**" ], - "deps": { - "common": [ - { - "id": "typenum 1.20.1", - "target": "typenum" - } - ], - "selects": {} - }, - "edition": "2024", - "version": "0.4.15" + "edition": "2015", + "version": "1.0.3" }, - "license": "MIT OR Apache-2.0", + "license": "Apache-2.0 OR MIT", "license_ids": [ "Apache-2.0", "MIT" ], "license_file": "LICENSE-APACHE" }, - "indexmap 2.14.2": { - "name": "indexmap", - "version": "2.14.2", - "package_url": "https://github.com/indexmap-rs/indexmap", + "flate2 1.1.11": { + "name": "flate2", + "version": "1.1.11", + "package_url": "https://github.com/rust-lang/flate2-rs", "repository": { "Http": { - "url": "https://static.crates.io/crates/indexmap/2.14.2/download", - "sha256": "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" + "url": "https://static.crates.io/crates/flate2/1.1.11/download", + "sha256": "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" } }, "targets": [ { "Library": { - "crate_name": "indexmap", + "crate_name": "flate2", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -971,55 +1102,58 @@ } } ], - "library_target_name": "indexmap", + "library_target_name": "flate2", "common_attrs": { "compile_data_glob": [ "**" ], "crate_features": { "common": [ + "any_impl", "default", - "std" + "miniz_oxide", + "runtime_detection", + "rust_backend" ], "selects": {} }, "deps": { "common": [ { - "id": "equivalent 1.0.3", - "target": "equivalent" + "id": "crc32fast 1.5.4", + "target": "crc32fast" }, { - "id": "hashbrown 0.17.1", - "target": "hashbrown" + "id": "miniz_oxide 0.9.1", + "target": "miniz_oxide" } ], "selects": {} }, - "edition": "2024", - "version": "2.14.2" + "edition": "2018", + "version": "1.1.11" }, - "license": "Apache-2.0 OR MIT", + "license": "MIT OR Apache-2.0", "license_ids": [ "Apache-2.0", "MIT" ], "license_file": "LICENSE-APACHE" }, - "lexopt 0.3.2": { - "name": "lexopt", - "version": "0.3.2", - "package_url": "https://github.com/blyxxyz/lexopt", + "form_urlencoded 1.2.2": { + "name": "form_urlencoded", + "version": "1.2.2", + "package_url": "https://github.com/servo/rust-url", "repository": { "Http": { - "url": "https://static.crates.io/crates/lexopt/0.3.2/download", - "sha256": "803ec87c9cfb29b9d2633f20cba1f488db3fd53f2158b1024cbefb47ba05d413" + "url": "https://static.crates.io/crates/form_urlencoded/1.2.2/download", + "sha256": "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" } }, "targets": [ { "Library": { - "crate_name": "lexopt", + "crate_name": "form_urlencoded", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1030,34 +1164,51 @@ } } ], - "library_target_name": "lexopt", + "library_target_name": "form_urlencoded", "common_attrs": { "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "alloc", + "std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "percent-encoding 2.3.2", + "target": "percent_encoding" + } + ], + "selects": {} + }, "edition": "2018", - "version": "0.3.2" + "version": "1.2.2" }, - "license": "MIT", + "license": "MIT OR Apache-2.0", "license_ids": [ + "Apache-2.0", "MIT" ], - "license_file": "LICENSE" + "license_file": "LICENSE-APACHE" }, - "libc 0.2.191": { - "name": "libc", - "version": "0.2.191", - "package_url": "https://github.com/rust-lang/libc", + "fs-err 3.3.2": { + "name": "fs-err", + "version": "3.3.2", + "package_url": "https://github.com/andrewhickman/fs-err", "repository": { "Http": { - "url": "https://static.crates.io/crates/libc/0.2.191/download", - "sha256": "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + "url": "https://static.crates.io/crates/fs-err/3.3.2/download", + "sha256": "b5c95b673b8f6f7235229ae11c5642d81b04c2e64c1e2fb417bc0cf73ca45f29" } }, "targets": [ { "Library": { - "crate_name": "libc", + "crate_name": "fs_err", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1080,34 +1231,19 @@ } } ], - "library_target_name": "libc", + "library_target_name": "fs_err", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { - "common": [], - "selects": { - "aarch64-apple-darwin": [ - "default", - "extra_traits", - "std" - ], - "x86_64-apple-darwin": [ - "default", - "extra_traits", - "std" - ] - } - }, "extra_deps": { "common": [ ":build_script_build" ], "selects": {} }, - "edition": "2021", - "version": "0.2.191" + "edition": "2018", + "version": "3.3.2" }, "build_script_attrs": { "compile_data_glob": [ @@ -1118,7 +1254,16 @@ ], "data_glob": [ "**" - ] + ], + "deps": { + "common": [ + { + "id": "autocfg 1.5.1", + "target": "autocfg" + } + ], + "selects": {} + } }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -1127,20 +1272,20 @@ ], "license_file": "LICENSE-APACHE" }, - "memchr 2.8.3": { - "name": "memchr", - "version": "2.8.3", - "package_url": "https://github.com/BurntSushi/memchr", + "hashbrown 0.17.1": { + "name": "hashbrown", + "version": "0.17.1", + "package_url": "https://github.com/rust-lang/hashbrown", "repository": { "Http": { - "url": "https://static.crates.io/crates/memchr/2.8.3/download", - "sha256": "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + "url": "https://static.crates.io/crates/hashbrown/0.17.1/download", + "sha256": "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" } }, "targets": [ { "Library": { - "crate_name": "memchr", + "crate_name": "hashbrown", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1151,43 +1296,35 @@ } } ], - "library_target_name": "memchr", + "library_target_name": "hashbrown", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { - "common": [ - "alloc", - "default", - "std" - ], - "selects": {} - }, - "edition": "2021", - "version": "2.8.3" + "edition": "2024", + "version": "0.17.1" }, - "license": "Unlicense OR MIT", + "license": "MIT OR Apache-2.0", "license_ids": [ - "MIT", - "Unlicense" + "Apache-2.0", + "MIT" ], - "license_file": "LICENSE-MIT" + "license_file": "LICENSE-APACHE" }, - "miniz_oxide 0.9.1": { - "name": "miniz_oxide", - "version": "0.9.1", - "package_url": "https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide", + "hybrid-array 0.4.15": { + "name": "hybrid-array", + "version": "0.4.15", + "package_url": "https://github.com/RustCrypto/hybrid-array", "repository": { "Http": { - "url": "https://static.crates.io/crates/miniz_oxide/0.9.1/download", - "sha256": "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" + "url": "https://static.crates.io/crates/hybrid-array/0.4.15/download", + "sha256": "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" } }, "targets": [ { "Library": { - "crate_name": "miniz_oxide", + "crate_name": "hybrid_array", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1198,58 +1335,3379 @@ } } ], - "library_target_name": "miniz_oxide", + "library_target_name": "hybrid_array", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { - "common": [ - "default", - "simd", - "simd-adler32", - "with-alloc" - ], - "selects": {} - }, "deps": { "common": [ { - "id": "adler2 2.0.1", - "target": "adler2" - }, - { - "id": "simd-adler32 0.3.10", - "target": "simd_adler32" + "id": "typenum 1.20.1", + "target": "typenum" } ], "selects": {} }, - "edition": "2021", - "version": "0.9.1" + "edition": "2024", + "version": "0.4.15" }, - "license": "MIT OR Zlib OR Apache-2.0", + "license": "MIT OR Apache-2.0", "license_ids": [ "Apache-2.0", - "MIT", - "Zlib" + "MIT" ], - "license_file": "LICENSE" + "license_file": "LICENSE-APACHE" }, - "nix 0.31.3": { - "name": "nix", + "icu_collections 2.4.0": { + "name": "icu_collections", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_collections/2.4.0/download", + "sha256": "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_collections", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_collections", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "potential_utf 0.1.6", + "target": "potential_utf" + }, + { + "id": "utf8_iter 1.1.0", + "target": "utf8_iter" + }, + { + "id": "yoke 0.8.4", + "target": "yoke" + }, + { + "id": "zerofrom 0.1.8", + "target": "zerofrom" + }, + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2024", + "proc_macro_deps": { + "common": [ + { + "id": "displaydoc 0.2.7", + "target": "displaydoc" + } + ], + "selects": {} + }, + "version": "2.4.0" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "icu_locale_core 2.4.0": { + "name": "icu_locale_core", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_locale_core/2.4.0/download", + "sha256": "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_locale_core", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_locale_core", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "zerovec" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "litemap 0.8.3", + "target": "litemap" + }, + { + "id": "tinystr 0.8.5", + "target": "tinystr" + }, + { + "id": "writeable 0.6.4", + "target": "writeable" + }, + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2024", + "proc_macro_deps": { + "common": [ + { + "id": "displaydoc 0.2.7", + "target": "displaydoc" + } + ], + "selects": {} + }, + "version": "2.4.0" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "icu_normalizer 2.4.0": { + "name": "icu_normalizer", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_normalizer/2.4.0/download", + "sha256": "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_normalizer", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_normalizer", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "compiled_data" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "icu_collections 2.4.0", + "target": "icu_collections" + }, + { + "id": "icu_normalizer_data 2.4.0", + "target": "icu_normalizer_data" + }, + { + "id": "icu_provider 2.4.0", + "target": "icu_provider" + }, + { + "id": "smallvec 1.16.5", + "target": "smallvec" + }, + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2024", + "version": "2.4.0" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "icu_normalizer_data 2.4.0": { + "name": "icu_normalizer_data", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_normalizer_data/2.4.0/download", + "sha256": "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_normalizer_data", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_normalizer_data", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2024", + "version": "2.4.0" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "icu_properties 2.4.0": { + "name": "icu_properties", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_properties/2.4.0/download", + "sha256": "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_properties", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_properties", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "compiled_data" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "icu_collections 2.4.0", + "target": "icu_collections" + }, + { + "id": "icu_locale_core 2.4.0", + "target": "icu_locale_core" + }, + { + "id": "icu_properties_data 2.4.0", + "target": "icu_properties_data" + }, + { + "id": "icu_provider 2.4.0", + "target": "icu_provider" + }, + { + "id": "zerotrie 0.2.5", + "target": "zerotrie" + }, + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2024", + "proc_macro_deps": { + "common": [ + { + "id": "displaydoc 0.2.7", + "target": "displaydoc" + } + ], + "selects": {} + }, + "version": "2.4.0" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "icu_properties_data 2.4.0": { + "name": "icu_properties_data", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_properties_data/2.4.0/download", + "sha256": "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_properties_data", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_properties_data", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2024", + "version": "2.4.0" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "icu_provider 2.4.0": { + "name": "icu_provider", + "version": "2.4.0", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/icu_provider/2.4.0/download", + "sha256": "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" + } + }, + "targets": [ + { + "Library": { + "crate_name": "icu_provider", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "icu_provider", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "baked" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "icu_locale_core 2.4.0", + "target": "icu_locale_core" + }, + { + "id": "writeable 0.6.4", + "target": "writeable" + }, + { + "id": "yoke 0.8.4", + "target": "yoke" + }, + { + "id": "zerofrom 0.1.8", + "target": "zerofrom" + }, + { + "id": "zerotrie 0.2.5", + "target": "zerotrie" + }, + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2024", + "proc_macro_deps": { + "common": [ + { + "id": "displaydoc 0.2.7", + "target": "displaydoc" + } + ], + "selects": {} + }, + "version": "2.4.0" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "idna 1.1.0": { + "name": "idna", + "version": "1.1.0", + "package_url": "https://github.com/servo/rust-url/", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/idna/1.1.0/download", + "sha256": "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" + } + }, + "targets": [ + { + "Library": { + "crate_name": "idna", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "idna", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "compiled_data", + "std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "idna_adapter 1.2.2", + "target": "idna_adapter" + }, + { + "id": "smallvec 1.16.5", + "target": "smallvec" + }, + { + "id": "utf8_iter 1.1.0", + "target": "utf8_iter" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.1.0" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "idna_adapter 1.2.2": { + "name": "idna_adapter", + "version": "1.2.2", + "package_url": "https://github.com/hsivonen/idna_adapter", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/idna_adapter/1.2.2/download", + "sha256": "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" + } + }, + "targets": [ + { + "Library": { + "crate_name": "idna_adapter", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "idna_adapter", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "compiled_data" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "icu_normalizer 2.4.0", + "target": "icu_normalizer" + }, + { + "id": "icu_properties 2.4.0", + "target": "icu_properties" + } + ], + "selects": {} + }, + "edition": "2024", + "version": "1.2.2" + }, + "license": "Apache-2.0 OR MIT", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "indexmap 2.14.2": { + "name": "indexmap", + "version": "2.14.2", + "package_url": "https://github.com/indexmap-rs/indexmap", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/indexmap/2.14.2/download", + "sha256": "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" + } + }, + "targets": [ + { + "Library": { + "crate_name": "indexmap", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "indexmap", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "equivalent 1.0.3", + "target": "equivalent" + }, + { + "id": "hashbrown 0.17.1", + "target": "hashbrown" + } + ], + "selects": {} + }, + "edition": "2024", + "version": "2.14.2" + }, + "license": "Apache-2.0 OR MIT", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "itertools 0.13.0": { + "name": "itertools", + "version": "0.13.0", + "package_url": "https://github.com/rust-itertools/itertools", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/itertools/0.13.0/download", + "sha256": "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" + } + }, + "targets": [ + { + "Library": { + "crate_name": "itertools", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "itertools", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "use_alloc", + "use_std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "either 1.19.0", + "target": "either" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.13.0" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "itoa 1.0.19": { + "name": "itoa", + "version": "1.0.19", + "package_url": "https://github.com/dtolnay/itoa", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/itoa/1.0.19/download", + "sha256": "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + } + }, + "targets": [ + { + "Library": { + "crate_name": "itoa", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "itoa", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "1.0.19" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "lexopt 0.3.2": { + "name": "lexopt", + "version": "0.3.2", + "package_url": "https://github.com/blyxxyz/lexopt", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/lexopt/0.3.2/download", + "sha256": "803ec87c9cfb29b9d2633f20cba1f488db3fd53f2158b1024cbefb47ba05d413" + } + }, + "targets": [ + { + "Library": { + "crate_name": "lexopt", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "lexopt", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.3.2" + }, + "license": "MIT", + "license_ids": [ + "MIT" + ], + "license_file": "LICENSE" + }, + "libc 0.2.191": { + "name": "libc", + "version": "0.2.191", + "package_url": "https://github.com/rust-lang/libc", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/libc/0.2.191/download", + "sha256": "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + } + }, + "targets": [ + { + "Library": { + "crate_name": "libc", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "libc", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [], + "selects": { + "aarch64-apple-darwin": [ + "default", + "extra_traits", + "std" + ], + "x86_64-apple-darwin": [ + "default", + "extra_traits", + "std" + ] + } + }, + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "version": "0.2.191" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "litemap 0.8.3": { + "name": "litemap", + "version": "0.8.3", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/litemap/0.8.3/download", + "sha256": "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + } + }, + "targets": [ + { + "Library": { + "crate_name": "litemap", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "litemap", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "0.8.3" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "memchr 2.8.3": { + "name": "memchr", + "version": "2.8.3", + "package_url": "https://github.com/BurntSushi/memchr", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/memchr/2.8.3/download", + "sha256": "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + } + }, + "targets": [ + { + "Library": { + "crate_name": "memchr", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "memchr", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "default", + "std" + ], + "selects": {} + }, + "edition": "2021", + "version": "2.8.3" + }, + "license": "Unlicense OR MIT", + "license_ids": [ + "MIT", + "Unlicense" + ], + "license_file": "LICENSE-MIT" + }, + "miniz_oxide 0.9.1": { + "name": "miniz_oxide", + "version": "0.9.1", + "package_url": "https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/miniz_oxide/0.9.1/download", + "sha256": "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "miniz_oxide", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "miniz_oxide", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "simd", + "simd-adler32", + "with-alloc" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "adler2 2.0.1", + "target": "adler2" + }, + { + "id": "simd-adler32 0.3.10", + "target": "simd_adler32" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.9.1" + }, + "license": "MIT OR Zlib OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT", + "Zlib" + ], + "license_file": "LICENSE" + }, + "nix 0.31.3": { + "name": "nix", "version": "0.31.3", "package_url": "https://github.com/nix-rust/nix", "repository": { "Http": { - "url": "https://static.crates.io/crates/nix/0.31.3/download", - "sha256": "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" + "url": "https://static.crates.io/crates/nix/0.31.3/download", + "sha256": "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "nix", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "nix", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "fs" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "bitflags 2.13.2", + "target": "bitflags" + }, + { + "id": "cfg-if 1.0.5", + "target": "cfg_if" + }, + { + "id": "libc 0.2.191", + "target": "libc" + } + ], + "selects": {} + }, + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "version": "0.31.3" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "cfg_aliases 0.2.2", + "target": "cfg_aliases" + } + ], + "selects": {} + } + }, + "license": "MIT", + "license_ids": [ + "MIT" + ], + "license_file": "LICENSE" + }, + "once_cell 1.21.4": { + "name": "once_cell", + "version": "1.21.4", + "package_url": "https://github.com/matklad/once_cell", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/once_cell/1.21.4/download", + "sha256": "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + } + }, + "targets": [ + { + "Library": { + "crate_name": "once_cell", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "once_cell", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "default", + "race", + "std" + ], + "selects": {} + }, + "edition": "2021", + "version": "1.21.4" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "os_str_bytes 7.2.1": { + "name": "os_str_bytes", + "version": "7.2.1", + "package_url": "https://github.com/dylni/os_str_bytes", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/os_str_bytes/7.2.1/download", + "sha256": "73b489f051c9d2f4299ddf8d55e33c65c86a7b76f49359af15f79ebe541d1595" + } + }, + "targets": [ + { + "Library": { + "crate_name": "os_str_bytes", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "os_str_bytes", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "memchr", + "raw_os_str" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "memchr 2.8.3", + "target": "memchr" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "7.2.1" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "pep440_rs 0.7.3": { + "name": "pep440_rs", + "version": "0.7.3", + "package_url": "https://github.com/konstin/pep440-rs", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/pep440_rs/0.7.3/download", + "sha256": "31095ca1f396e3de32745f42b20deef7bc09077f918b085307e8eab6ddd8fb9c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "pep440_rs", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "pep440_rs", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "version-ranges" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "once_cell 1.21.4", + "target": "once_cell" + }, + { + "id": "serde 1.0.229", + "target": "serde" + }, + { + "id": "unicode-width 0.2.3", + "target": "unicode_width" + }, + { + "id": "unscanny 0.1.0", + "target": "unscanny" + }, + { + "id": "version-ranges 0.1.3", + "target": "version_ranges" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.7.3" + }, + "license": "Apache-2.0 OR BSD-2-Clause", + "license_ids": [ + "Apache-2.0", + "BSD-2-Clause" + ], + "license_file": "License-Apache" + }, + "pep508_rs 0.9.2": { + "name": "pep508_rs", + "version": "0.9.2", + "package_url": "https://github.com/konstin/pep508_rs", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/pep508_rs/0.9.2/download", + "sha256": "faee7227064121fcadcd2ff788ea26f0d8f2bd23a0574da11eca23bc935bcc05" + } + }, + "targets": [ + { + "Library": { + "crate_name": "pep508_rs", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "pep508_rs", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "boxcar 0.2.14", + "target": "boxcar" + }, + { + "id": "indexmap 2.14.2", + "target": "indexmap" + }, + { + "id": "itertools 0.13.0", + "target": "itertools" + }, + { + "id": "once_cell 1.21.4", + "target": "once_cell" + }, + { + "id": "pep440_rs 0.7.3", + "target": "pep440_rs" + }, + { + "id": "regex 1.13.1", + "target": "regex" + }, + { + "id": "rustc-hash 2.1.3", + "target": "rustc_hash" + }, + { + "id": "serde 1.0.229", + "target": "serde" + }, + { + "id": "smallvec 1.16.5", + "target": "smallvec" + }, + { + "id": "thiserror 1.0.69", + "target": "thiserror" + }, + { + "id": "unicode-width 0.2.3", + "target": "unicode_width" + }, + { + "id": "url 2.5.8", + "target": "url" + }, + { + "id": "urlencoding 2.1.3", + "target": "urlencoding" + }, + { + "id": "version-ranges 0.1.3", + "target": "version_ranges" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.9.2" + }, + "license": "Apache-2.0 OR BSD-2-Clause", + "license_ids": [ + "Apache-2.0", + "BSD-2-Clause" + ], + "license_file": "License-Apache" + }, + "percent-encoding 2.3.2": { + "name": "percent-encoding", + "version": "2.3.2", + "package_url": "https://github.com/servo/rust-url/", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/percent-encoding/2.3.2/download", + "sha256": "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + } + }, + "targets": [ + { + "Library": { + "crate_name": "percent_encoding", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "percent_encoding", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "std" + ], + "selects": {} + }, + "edition": "2018", + "version": "2.3.2" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "potential_utf 0.1.6": { + "name": "potential_utf", + "version": "0.1.6", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/potential_utf/0.1.6/download", + "sha256": "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" + } + }, + "targets": [ + { + "Library": { + "crate_name": "potential_utf", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "potential_utf", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "zerovec" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.1.6" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "proc-macro2 1.0.107": { + "name": "proc-macro2", + "version": "1.0.107", + "package_url": "https://github.com/dtolnay/proc-macro2", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/proc-macro2/1.0.107/download", + "sha256": "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" + } + }, + "targets": [ + { + "Library": { + "crate_name": "proc_macro2", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "proc_macro2", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "proc-macro" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "unicode-ident 1.0.27", + "target": "unicode_ident" + } + ], + "selects": {} + }, + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "version": "1.0.107" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "quote 1.0.47": { + "name": "quote", + "version": "1.0.47", + "package_url": "https://github.com/dtolnay/quote", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/quote/1.0.47/download", + "sha256": "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" + } + }, + "targets": [ + { + "Library": { + "crate_name": "quote", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "quote", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "proc-macro" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + } + ], + "selects": {} + }, + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "version": "1.0.47" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "regex 1.13.1": { + "name": "regex", + "version": "1.13.1", + "package_url": "https://github.com/rust-lang/regex", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/regex/1.13.1/download", + "sha256": "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "regex", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "regex", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "perf", + "perf-backtrack", + "perf-cache", + "perf-dfa", + "perf-inline", + "perf-literal", + "perf-onepass", + "std", + "unicode", + "unicode-age", + "unicode-bool", + "unicode-case", + "unicode-gencat", + "unicode-perl", + "unicode-script", + "unicode-segment" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "aho-corasick 1.1.5", + "target": "aho_corasick" + }, + { + "id": "memchr 2.8.3", + "target": "memchr" + }, + { + "id": "regex-automata 0.4.18", + "target": "regex_automata" + }, + { + "id": "regex-syntax 0.8.11", + "target": "regex_syntax" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "1.13.1" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "regex-automata 0.4.18": { + "name": "regex-automata", + "version": "0.4.18", + "package_url": "https://github.com/rust-lang/regex", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/regex-automata/0.4.18/download", + "sha256": "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" + } + }, + "targets": [ + { + "Library": { + "crate_name": "regex_automata", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "regex_automata", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "dfa-onepass", + "hybrid", + "meta", + "nfa-backtrack", + "nfa-pikevm", + "nfa-thompson", + "perf-inline", + "perf-literal", + "perf-literal-multisubstring", + "perf-literal-substring", + "std", + "syntax", + "unicode", + "unicode-age", + "unicode-bool", + "unicode-case", + "unicode-gencat", + "unicode-perl", + "unicode-script", + "unicode-segment", + "unicode-word-boundary" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "aho-corasick 1.1.5", + "target": "aho_corasick" + }, + { + "id": "memchr 2.8.3", + "target": "memchr" + }, + { + "id": "regex-syntax 0.8.11", + "target": "regex_syntax" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.4.18" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "regex-syntax 0.8.11": { + "name": "regex-syntax", + "version": "0.8.11", + "package_url": "https://github.com/rust-lang/regex", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/regex-syntax/0.8.11/download", + "sha256": "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + } + }, + "targets": [ + { + "Library": { + "crate_name": "regex_syntax", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "regex_syntax", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "std", + "unicode", + "unicode-age", + "unicode-bool", + "unicode-case", + "unicode-gencat", + "unicode-perl", + "unicode-script", + "unicode-segment" + ], + "selects": {} + }, + "edition": "2021", + "version": "0.8.11" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "rules_python_crates 0.0.1": { + "name": "rules_python_crates", + "version": "0.0.1", + "package_url": null, + "repository": null, + "targets": [ + { + "Library": { + "crate_name": "rules_python_crates", + "crate_root": "shrubbery/src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "rules_python_crates", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "anyhow 1.0.104", + "target": "anyhow" + }, + { + "id": "argfile 1.0.0", + "target": "argfile" + }, + { + "id": "base64 0.23.1", + "target": "base64" + }, + { + "id": "csv 1.4.0", + "target": "csv" + }, + { + "id": "flate2 1.1.11", + "target": "flate2" + }, + { + "id": "lexopt 0.3.2", + "target": "lexopt" + }, + { + "id": "pep440_rs 0.7.3", + "target": "pep440_rs" + }, + { + "id": "pep508_rs 0.9.2", + "target": "pep508_rs" + }, + { + "id": "regex 1.13.1", + "target": "regex" + }, + { + "id": "sha2 0.11.1", + "target": "sha2" + }, + { + "id": "zip 9.0.5", + "target": "zip" + } + ], + "selects": {} + }, + "edition": "2024", + "version": "0.0.1" + }, + "license": null, + "license_ids": [], + "license_file": null + }, + "rustc-hash 2.1.3": { + "name": "rustc-hash", + "version": "2.1.3", + "package_url": "https://github.com/rust-lang/rustc-hash", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/rustc-hash/2.1.3/download", + "sha256": "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rustc_hash", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "rustc_hash", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "std" + ], + "selects": {} + }, + "edition": "2021", + "version": "2.1.3" + }, + "license": "Apache-2.0 OR MIT", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "ryu 1.0.23": { + "name": "ryu", + "version": "1.0.23", + "package_url": "https://github.com/dtolnay/ryu", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/ryu/1.0.23/download", + "sha256": "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + } + }, + "targets": [ + { + "Library": { + "crate_name": "ryu", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "ryu", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "1.0.23" + }, + "license": "Apache-2.0 OR BSL-1.0", + "license_ids": [ + "Apache-2.0", + "BSL-1.0" + ], + "license_file": "LICENSE-APACHE" + }, + "serde 1.0.229": { + "name": "serde", + "version": "1.0.229", + "package_url": "https://github.com/serde-rs/serde", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/serde/1.0.229/download", + "sha256": "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" + } + }, + "targets": [ + { + "Library": { + "crate_name": "serde", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "serde", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "derive", + "rc", + "serde_derive", + "std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "serde_core 1.0.229", + "target": "serde_core" + } + ], + "selects": {} + }, + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { + "common": [ + { + "id": "serde_derive 1.0.229", + "target": "serde_derive" + } + ], + "selects": {} + }, + "version": "1.0.229" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "serde_core 1.0.229": { + "name": "serde_core", + "version": "1.0.229", + "package_url": "https://github.com/serde-rs/serde", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/serde_core/1.0.229/download", + "sha256": "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" + } + }, + "targets": [ + { + "Library": { + "crate_name": "serde_core", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "serde_core", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "rc", + "result", + "std" + ], + "selects": {} + }, + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { + "common": [], + "selects": { + "cfg(any())": [ + { + "id": "serde_derive 1.0.229", + "target": "serde_derive" + } + ] + } + }, + "version": "1.0.229" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "serde_derive 1.0.229": { + "name": "serde_derive", + "version": "1.0.229", + "package_url": "https://github.com/serde-rs/serde", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/serde_derive/1.0.229/download", + "sha256": "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "serde_derive", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "serde_derive", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 3.0.10", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "1.0.229" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "sha2 0.11.1": { + "name": "sha2", + "version": "0.11.1", + "package_url": "https://github.com/RustCrypto/hashes", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/sha2/0.11.1/download", + "sha256": "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" + } + }, + "targets": [ + { + "Library": { + "crate_name": "sha2", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "sha2", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "default", + "oid" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "cfg-if 1.0.5", + "target": "cfg_if" + }, + { + "id": "digest 0.11.3", + "target": "digest" + } + ], + "selects": { + "cfg(any(target_arch = \"aarch64\", target_arch = \"x86_64\", target_arch = \"x86\"))": [ + { + "id": "cpufeatures 0.3.1", + "target": "cpufeatures" + } + ] + } + }, + "edition": "2024", + "version": "0.11.1" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "simd-adler32 0.3.10": { + "name": "simd-adler32", + "version": "0.3.10", + "package_url": "https://github.com/mcountryman/simd-adler32", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/simd-adler32/0.3.10/download", + "sha256": "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + } + }, + "targets": [ + { + "Library": { + "crate_name": "simd_adler32", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "simd_adler32", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.3.10" + }, + "license": "MIT", + "license_ids": [ + "MIT" + ], + "license_file": "LICENSE.md" + }, + "smallvec 1.16.5": { + "name": "smallvec", + "version": "1.16.5", + "package_url": "https://github.com/servo/rust-smallvec", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/smallvec/1.16.5/download", + "sha256": "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + } + }, + "targets": [ + { + "Library": { + "crate_name": "smallvec", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "smallvec", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "const_generics", + "union" + ], + "selects": {} + }, + "edition": "2018", + "version": "1.16.5" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "stable_deref_trait 1.2.1": { + "name": "stable_deref_trait", + "version": "1.2.1", + "package_url": "https://github.com/storyyeller/stable_deref_trait", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/stable_deref_trait/1.2.1/download", + "sha256": "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + } + }, + "targets": [ + { + "Library": { + "crate_name": "stable_deref_trait", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "stable_deref_trait", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "1.2.1" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "syn 2.0.119": { + "name": "syn", + "version": "2.0.119", + "package_url": "https://github.com/dtolnay/syn", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/syn/2.0.119/download", + "sha256": "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" + } + }, + "targets": [ + { + "Library": { + "crate_name": "syn", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "syn", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "clone-impls", + "default", + "derive", + "parsing", + "printing", + "proc-macro" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "unicode-ident 1.0.27", + "target": "unicode_ident" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "2.0.119" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "syn 3.0.10": { + "name": "syn", + "version": "3.0.10", + "package_url": "https://github.com/dtolnay/syn", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/syn/3.0.10/download", + "sha256": "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" + } + }, + "targets": [ + { + "Library": { + "crate_name": "syn", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "syn", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "clone-impls", + "default", + "derive", + "extra-traits", + "fold", + "parsing", + "printing", + "proc-macro", + "visit" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "unicode-ident 1.0.27", + "target": "unicode_ident" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "3.0.10" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "synstructure 0.14.0": { + "name": "synstructure", + "version": "0.14.0", + "package_url": "https://github.com/mystor/synstructure", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/synstructure/0.14.0/download", + "sha256": "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" + } + }, + "targets": [ + { + "Library": { + "crate_name": "synstructure", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "synstructure", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "proc-macro" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 3.0.10", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.14.0" + }, + "license": "MIT", + "license_ids": [ + "MIT" + ], + "license_file": "LICENSE" + }, + "thiserror 1.0.69": { + "name": "thiserror", + "version": "1.0.69", + "package_url": "https://github.com/dtolnay/thiserror", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/thiserror/1.0.69/download", + "sha256": "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" + } + }, + "targets": [ + { + "Library": { + "crate_name": "thiserror", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "thiserror", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "extra_deps": { + "common": [ + ":build_script_build" + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { + "common": [ + { + "id": "thiserror-impl 1.0.69", + "target": "thiserror_impl" + } + ], + "selects": {} + }, + "version": "1.0.69" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "thiserror-impl 1.0.69": { + "name": "thiserror-impl", + "version": "1.0.69", + "package_url": "https://github.com/dtolnay/thiserror", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/thiserror-impl/1.0.69/download", + "sha256": "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "thiserror_impl", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "thiserror_impl", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 2.0.119", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "1.0.69" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "tinystr 0.8.5": { + "name": "tinystr", + "version": "0.8.5", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/tinystr/0.8.5/download", + "sha256": "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" + } + }, + "targets": [ + { + "Library": { + "crate_name": "tinystr", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "tinystr", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "zerovec" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "zerovec 0.11.9", + "target": "zerovec" + } + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { + "common": [ + { + "id": "displaydoc 0.2.7", + "target": "displaydoc" + } + ], + "selects": {} + }, + "version": "0.8.5" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "typed-path 0.12.4": { + "name": "typed-path", + "version": "0.12.4", + "package_url": "https://github.com/chipsenkbeil/typed-path", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/typed-path/0.12.4/download", + "sha256": "54ec2755506471f54baf5e4bb5499d8e510cc1caf271270e778a736bd2d7336c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "typed_path", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "typed_path", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "std" + ], + "selects": {} + }, + "edition": "2021", + "version": "0.12.4" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "typenum 1.20.1": { + "name": "typenum", + "version": "1.20.1", + "package_url": "https://github.com/paholg/typenum", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/typenum/1.20.1/download", + "sha256": "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + } + }, + "targets": [ + { + "Library": { + "crate_name": "typenum", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "typenum", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "const-generics" + ], + "selects": {} + }, + "edition": "2018", + "version": "1.20.1" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE" + }, + "unicode-ident 1.0.27": { + "name": "unicode-ident", + "version": "1.0.27", + "package_url": "https://github.com/dtolnay/unicode-ident", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/unicode-ident/1.0.27/download", + "sha256": "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + } + }, + "targets": [ + { + "Library": { + "crate_name": "unicode_ident", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "unicode_ident", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "1.0.27" + }, + "license": "(MIT OR Apache-2.0) AND Unicode-3.0", + "license_ids": [ + "Apache-2.0", + "MIT", + "Unicode-3.0" + ], + "license_file": "LICENSE-APACHE" + }, + "unicode-width 0.2.3": { + "name": "unicode-width", + "version": "0.2.3", + "package_url": "https://github.com/unicode-rs/unicode-width", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/unicode-width/0.2.3/download", + "sha256": "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + } + }, + "targets": [ + { + "Library": { + "crate_name": "unicode_width", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "unicode_width", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "cjk", + "default" + ], + "selects": {} + }, + "edition": "2021", + "version": "0.2.3" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "unscanny 0.1.0": { + "name": "unscanny", + "version": "0.1.0", + "package_url": "https://github.com/typst/unscanny", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/unscanny/0.1.0/download", + "sha256": "e9df2af067a7953e9c3831320f35c1cc0600c30d44d9f7a12b01db1cd88d6b47" } }, "targets": [ { "Library": { - "crate_name": "nix", + "crate_name": "unscanny", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "unscanny", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "0.1.0" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "url 2.5.8": { + "name": "url", + "version": "2.5.8", + "package_url": "https://github.com/servo/rust-url", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/url/2.5.8/download", + "sha256": "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" + } + }, + "targets": [ + { + "Library": { + "crate_name": "url", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "url", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "serde", + "std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "form_urlencoded 1.2.2", + "target": "form_urlencoded" + }, + { + "id": "idna 1.1.0", + "target": "idna" + }, + { + "id": "percent-encoding 2.3.2", + "target": "percent_encoding" + }, + { + "id": "serde 1.0.229", + "target": "serde" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "serde_derive 1.0.229", + "target": "serde_derive" + } + ], + "selects": {} + }, + "version": "2.5.8" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "urlencoding 2.1.3": { + "name": "urlencoding", + "version": "2.1.3", + "package_url": "https://github.com/kornelski/rust_urlencoding", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/urlencoding/2.1.3/download", + "sha256": "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + } + }, + "targets": [ + { + "Library": { + "crate_name": "urlencoding", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "urlencoding", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "2.1.3" + }, + "license": "MIT", + "license_ids": [ + "MIT" + ], + "license_file": "LICENSE" + }, + "utf8_iter 1.1.0": { + "name": "utf8_iter", + "version": "1.1.0", + "package_url": "https://github.com/hsivonen/utf8_iter", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/utf8_iter/1.1.0/download", + "sha256": "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" + } + }, + "targets": [ + { + "Library": { + "crate_name": "utf8_iter", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "utf8_iter", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "utf_types 1.0.0", + "target": "utf_types" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "1.1.0" + }, + "license": "Apache-2.0 OR MIT", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "utf_types 1.0.0": { + "name": "utf_types", + "version": "1.0.0", + "package_url": "https://github.com/hsivonen/utf_types", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/utf_types/1.0.0/download", + "sha256": "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + } + }, + "targets": [ + { + "Library": { + "crate_name": "utf_types", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "utf_types", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "1.0.0" + }, + "license": "Apache-2.0 OR MIT", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "version-ranges 0.1.3": { + "name": "version-ranges", + "version": "0.1.3", + "package_url": "https://github.com/pubgrub-rs/pubgrub", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/version-ranges/0.1.3/download", + "sha256": "31e9bd4e9c9ff6a2a9b5969462ba26216af3e010df0377dad8320ab515262ef8" + } + }, + "targets": [ + { + "Library": { + "crate_name": "version_ranges", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1258,11 +4716,84 @@ ] } } + } + ], + "library_target_name": "version_ranges", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "smallvec 1.16.5", + "target": "smallvec" + } + ], + "selects": {} }, + "edition": "2021", + "version": "0.1.3" + }, + "license": "MPL-2.0", + "license_ids": [ + "MPL-2.0" + ], + "license_file": "LICENSE" + }, + "writeable 0.6.4": { + "name": "writeable", + "version": "0.6.4", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/writeable/0.6.4/download", + "sha256": "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + } + }, + "targets": [ + { + "Library": { + "crate_name": "writeable", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "writeable", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "0.6.4" + }, + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" + }, + "yoke 0.8.4": { + "name": "yoke", + "version": "0.8.4", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/yoke/0.8.4/download", + "sha256": "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" + } + }, + "targets": [ { - "BuildScript": { - "crate_name": "build_script_build", - "crate_root": "build.rs", + "Library": { + "crate_name": "yoke", + "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, "include": [ @@ -1272,83 +4803,63 @@ } } ], - "library_target_name": "nix", + "library_target_name": "yoke", "common_attrs": { "compile_data_glob": [ "**" ], "crate_features": { "common": [ - "fs" + "derive", + "zerofrom" ], "selects": {} }, "deps": { "common": [ { - "id": "bitflags 2.13.2", - "target": "bitflags" - }, - { - "id": "cfg-if 1.0.5", - "target": "cfg_if" + "id": "stable_deref_trait 1.2.1", + "target": "stable_deref_trait" }, { - "id": "libc 0.2.191", - "target": "libc" + "id": "zerofrom 0.1.8", + "target": "zerofrom" } ], "selects": {} }, - "extra_deps": { - "common": [ - ":build_script_build" - ], - "selects": {} - }, "edition": "2021", - "version": "0.31.3" - }, - "build_script_attrs": { - "compile_data_glob": [ - "**" - ], - "compile_data_glob_excludes": [ - "**/*.rs" - ], - "data_glob": [ - "**" - ], - "deps": { + "proc_macro_deps": { "common": [ { - "id": "cfg_aliases 0.2.2", - "target": "cfg_aliases" + "id": "yoke-derive 0.8.4", + "target": "yoke_derive" } ], "selects": {} - } + }, + "version": "0.8.4" }, - "license": "MIT", + "license": "Unicode-3.0", "license_ids": [ - "MIT" + "Unicode-3.0" ], "license_file": "LICENSE" }, - "os_str_bytes 7.2.1": { - "name": "os_str_bytes", - "version": "7.2.1", - "package_url": "https://github.com/dylni/os_str_bytes", + "yoke-derive 0.8.4": { + "name": "yoke-derive", + "version": "0.8.4", + "package_url": "https://github.com/unicode-org/icu4x", "repository": { "Http": { - "url": "https://static.crates.io/crates/os_str_bytes/7.2.1/download", - "sha256": "73b489f051c9d2f4299ddf8d55e33c65c86a7b76f49359af15f79ebe541d1595" + "url": "https://static.crates.io/crates/yoke-derive/0.8.4/download", + "sha256": "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" } }, "targets": [ { - "Library": { - "crate_name": "os_str_bytes", + "ProcMacro": { + "crate_name": "yoke_derive", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1359,48 +4870,56 @@ } } ], - "library_target_name": "os_str_bytes", + "library_target_name": "yoke_derive", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { - "common": [ - "default", - "memchr", - "raw_os_str" - ], - "selects": {} - }, "deps": { "common": [ { - "id": "memchr 2.8.3", - "target": "memchr" + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 3.0.10", + "target": "syn" + }, + { + "id": "synstructure 0.14.0", + "target": "synstructure" } ], "selects": {} }, "edition": "2021", - "version": "7.2.1" + "version": "0.8.4" }, - "license": "MIT OR Apache-2.0", + "license": "Unicode-3.0", "license_ids": [ - "Apache-2.0", - "MIT" + "Unicode-3.0" ], - "license_file": "LICENSE-APACHE" + "license_file": "LICENSE" }, - "rules_python_crates 0.0.1": { - "name": "rules_python_crates", - "version": "0.0.1", - "package_url": null, - "repository": null, + "zerofrom 0.1.8": { + "name": "zerofrom", + "version": "0.1.8", + "package_url": "https://github.com/unicode-org/icu4x", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/zerofrom/0.1.8/download", + "sha256": "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" + } + }, "targets": [ { "Library": { - "crate_name": "rules_python_crates", - "crate_root": "shrubbery/src/lib.rs", + "crate_name": "zerofrom", + "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, "include": [ @@ -1410,61 +4929,49 @@ } } ], - "library_target_name": "rules_python_crates", + "library_target_name": "zerofrom", "common_attrs": { "compile_data_glob": [ "**" ], - "deps": { + "crate_features": { + "common": [ + "derive" + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { "common": [ { - "id": "anyhow 1.0.104", - "target": "anyhow" - }, - { - "id": "argfile 1.0.0", - "target": "argfile" - }, - { - "id": "flate2 1.1.11", - "target": "flate2" - }, - { - "id": "lexopt 0.3.2", - "target": "lexopt" - }, - { - "id": "sha2 0.11.1", - "target": "sha2" - }, - { - "id": "zip 9.0.5", - "target": "zip" + "id": "zerofrom-derive 0.1.8", + "target": "zerofrom_derive" } ], "selects": {} }, - "edition": "2024", - "version": "0.0.1" + "version": "0.1.8" }, - "license": null, - "license_ids": [], - "license_file": null + "license": "Unicode-3.0", + "license_ids": [ + "Unicode-3.0" + ], + "license_file": "LICENSE" }, - "sha2 0.11.1": { - "name": "sha2", - "version": "0.11.1", - "package_url": "https://github.com/RustCrypto/hashes", + "zerofrom-derive 0.1.8": { + "name": "zerofrom-derive", + "version": "0.1.8", + "package_url": "https://github.com/unicode-org/icu4x", "repository": { "Http": { - "url": "https://static.crates.io/crates/sha2/0.11.1/download", - "sha256": "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" + "url": "https://static.crates.io/crates/zerofrom-derive/0.1.8/download", + "sha256": "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" } }, "targets": [ { - "Library": { - "crate_name": "sha2", + "ProcMacro": { + "crate_name": "zerofrom_derive", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1475,63 +4982,55 @@ } } ], - "library_target_name": "sha2", + "library_target_name": "zerofrom_derive", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { - "common": [ - "alloc", - "default", - "oid" - ], - "selects": {} - }, "deps": { "common": [ { - "id": "cfg-if 1.0.5", - "target": "cfg_if" + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" }, { - "id": "digest 0.11.3", - "target": "digest" + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 3.0.10", + "target": "syn" + }, + { + "id": "synstructure 0.14.0", + "target": "synstructure" } ], - "selects": { - "cfg(any(target_arch = \"aarch64\", target_arch = \"x86_64\", target_arch = \"x86\"))": [ - { - "id": "cpufeatures 0.3.1", - "target": "cpufeatures" - } - ] - } + "selects": {} }, - "edition": "2024", - "version": "0.11.1" + "edition": "2021", + "version": "0.1.8" }, - "license": "MIT OR Apache-2.0", + "license": "Unicode-3.0", "license_ids": [ - "Apache-2.0", - "MIT" + "Unicode-3.0" ], - "license_file": "LICENSE-APACHE" + "license_file": "LICENSE" }, - "simd-adler32 0.3.10": { - "name": "simd-adler32", - "version": "0.3.10", - "package_url": "https://github.com/mcountryman/simd-adler32", + "zerotrie 0.2.5": { + "name": "zerotrie", + "version": "0.2.5", + "package_url": "https://github.com/unicode-org/icu4x", "repository": { "Http": { - "url": "https://static.crates.io/crates/simd-adler32/0.3.10/download", - "sha256": "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + "url": "https://static.crates.io/crates/zerotrie/0.2.5/download", + "sha256": "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" } }, "targets": [ { "Library": { - "crate_name": "simd_adler32", + "crate_name": "zerotrie", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1542,34 +5041,63 @@ } } ], - "library_target_name": "simd_adler32", + "library_target_name": "zerotrie", "common_attrs": { "compile_data_glob": [ "**" ], - "edition": "2018", - "version": "0.3.10" + "crate_features": { + "common": [ + "yoke", + "zerofrom" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "yoke 0.8.4", + "target": "yoke" + }, + { + "id": "zerofrom 0.1.8", + "target": "zerofrom" + } + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { + "common": [ + { + "id": "displaydoc 0.2.7", + "target": "displaydoc" + } + ], + "selects": {} + }, + "version": "0.2.5" }, - "license": "MIT", + "license": "Unicode-3.0", "license_ids": [ - "MIT" + "Unicode-3.0" ], - "license_file": "LICENSE.md" + "license_file": "LICENSE" }, - "typed-path 0.12.4": { - "name": "typed-path", - "version": "0.12.4", - "package_url": "https://github.com/chipsenkbeil/typed-path", + "zerovec 0.11.9": { + "name": "zerovec", + "version": "0.11.9", + "package_url": "https://github.com/unicode-org/icu4x", "repository": { "Http": { - "url": "https://static.crates.io/crates/typed-path/0.12.4/download", - "sha256": "54ec2755506471f54baf5e4bb5499d8e510cc1caf271270e778a736bd2d7336c" + "url": "https://static.crates.io/crates/zerovec/0.11.9/download", + "sha256": "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" } }, "targets": [ { "Library": { - "crate_name": "typed_path", + "crate_name": "zerovec", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1580,42 +5108,63 @@ } } ], - "library_target_name": "typed_path", + "library_target_name": "zerovec", "common_attrs": { "compile_data_glob": [ "**" ], "crate_features": { "common": [ - "default", - "std" + "derive", + "yoke" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "yoke 0.8.4", + "target": "yoke" + }, + { + "id": "zerofrom 0.1.8", + "target": "zerofrom" + } ], "selects": {} }, "edition": "2021", - "version": "0.12.4" + "proc_macro_deps": { + "common": [ + { + "id": "zerovec-derive 0.11.7", + "target": "zerovec_derive" + } + ], + "selects": {} + }, + "version": "0.11.9" }, - "license": "MIT OR Apache-2.0", + "license": "Unicode-3.0", "license_ids": [ - "Apache-2.0", - "MIT" + "Unicode-3.0" ], - "license_file": "LICENSE-APACHE" + "license_file": "LICENSE" }, - "typenum 1.20.1": { - "name": "typenum", - "version": "1.20.1", - "package_url": "https://github.com/paholg/typenum", + "zerovec-derive 0.11.7": { + "name": "zerovec-derive", + "version": "0.11.7", + "package_url": "https://github.com/unicode-org/icu4x", "repository": { "Http": { - "url": "https://static.crates.io/crates/typenum/1.20.1/download", - "sha256": "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + "url": "https://static.crates.io/crates/zerovec-derive/0.11.7/download", + "sha256": "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" } }, "targets": [ { - "Library": { - "crate_name": "typenum", + "ProcMacro": { + "crate_name": "zerovec_derive", "crate_root": "src/lib.rs", "srcs": { "allow_empty": true, @@ -1626,24 +5175,34 @@ } } ], - "library_target_name": "typenum", + "library_target_name": "zerovec_derive", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { + "deps": { "common": [ - "const-generics" + { + "id": "proc-macro2 1.0.107", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.47", + "target": "quote" + }, + { + "id": "syn 3.0.10", + "target": "syn" + } ], "selects": {} }, - "edition": "2018", - "version": "1.20.1" + "edition": "2021", + "version": "0.11.7" }, - "license": "MIT OR Apache-2.0", + "license": "Unicode-3.0", "license_ids": [ - "Apache-2.0", - "MIT" + "Unicode-3.0" ], "license_file": "LICENSE" }, @@ -1788,6 +5347,7 @@ "aarch64-apple-darwin" ], "cfg(all(target_arch = \"loongarch64\", target_os = \"linux\"))": [], + "cfg(any())": [], "cfg(any(target_arch = \"aarch64\", target_arch = \"x86_64\", target_arch = \"x86\"))": [ "aarch64-apple-darwin", "aarch64-pc-windows-msvc", @@ -1824,8 +5384,13 @@ "direct_deps": [ "anyhow 1.0.104", "argfile 1.0.0", + "base64 0.23.1", + "csv 1.4.0", "flate2 1.1.11", "lexopt 0.3.2", + "pep440_rs 0.7.3", + "pep508_rs 0.9.2", + "regex 1.13.1", "sha2 0.11.1", "zip 9.0.5" ], diff --git a/crates/Cargo.lock b/crates/Cargo.lock index 22e69799b1..4445a45432 100644 --- a/crates/Cargo.lock +++ b/crates/Cargo.lock @@ -8,6 +8,15 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" version = "1.0.104" @@ -30,6 +39,12 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "bitflags" version = "2.13.2" @@ -45,6 +60,12 @@ dependencies = [ "hybrid-array", ] +[[package]] +name = "boxcar" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f64beae40a84da1b4b26ff2761a5b895c12adc41dc25aaee1c4f2bbfe97a6e" + [[package]] name = "cfg-if" version = "1.0.5" @@ -90,6 +111,27 @@ dependencies = [ "hybrid-array", ] +[[package]] +name = "csv" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde_core", +] + +[[package]] +name = "csv-core" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" +dependencies = [ + "memchr", +] + [[package]] name = "digest" version = "0.11.3" @@ -101,6 +143,23 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + [[package]] name = "equivalent" version = "1.0.3" @@ -118,6 +177,15 @@ dependencies = [ "zlib-rs", ] +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs-err" version = "3.3.2" @@ -142,6 +210,110 @@ dependencies = [ "typenum", ] +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.14.2" @@ -152,6 +324,21 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + [[package]] name = "lexopt" version = "0.3.2" @@ -164,6 +351,12 @@ version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + [[package]] name = "memchr" version = "2.8.3" @@ -192,6 +385,12 @@ dependencies = [ "libc", ] +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + [[package]] name = "os_str_bytes" version = "7.2.1" @@ -201,18 +400,162 @@ dependencies = [ "memchr", ] +[[package]] +name = "pep440_rs" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31095ca1f396e3de32745f42b20deef7bc09077f918b085307e8eab6ddd8fb9c" +dependencies = [ + "once_cell", + "serde", + "unicode-width", + "unscanny", + "version-ranges", +] + +[[package]] +name = "pep508_rs" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faee7227064121fcadcd2ff788ea26f0d8f2bd23a0574da11eca23bc935bcc05" +dependencies = [ + "boxcar", + "indexmap", + "itertools", + "once_cell", + "pep440_rs", + "regex", + "rustc-hash", + "serde", + "smallvec", + "thiserror", + "unicode-width", + "url", + "urlencoding", + "version-ranges", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + [[package]] name = "rules_python_crates" version = "0.0.1" dependencies = [ "anyhow", "argfile", + "base64", + "csv", "flate2", "lexopt", + "pep440_rs", + "pep508_rs", + "regex", "sha2", "zip", ] +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "sha2" version = "0.11.1" @@ -230,6 +573,81 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "typed-path" version = "0.12.4" @@ -242,6 +660,150 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "unscanny" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9df2af067a7953e9c3831320f35c1cc0600c30d44d9f7a12b01db1cd88d6b47" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "version-ranges" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e9bd4e9c9ff6a2a9b5969462ba26216af3e010df0377dad8320ab515262ef8" +dependencies = [ + "smallvec", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "zip" version = "9.0.5" diff --git a/crates/Cargo.toml b/crates/Cargo.toml index b739064512..6871f66290 100644 --- a/crates/Cargo.toml +++ b/crates/Cargo.toml @@ -16,10 +16,15 @@ path = "shrubbery/src/lib.rs" # keep-sorted start anyhow = "1.0.104" argfile = "1.0.0" +base64 = "0.23.1" +csv = "1.4.0" # Transitive dep of zip: zip's `deflate-flate2` leaves the backend unset, so a # top-level pin keeps flate2 on its default pure-Rust backend. flate2 = "1.1.11" lexopt = "0.3.2" +pep440_rs = "0.7.3" +pep508_rs = "0.9.2" +regex = "1.13.1" sha2 = "0.11.1" # Disable default features (C zstd-sys bindings plus unused compression, # encryption, and time subsystems) and enable only `deflate-flate2`. diff --git a/crates/shrubbery/BUILD.bazel b/crates/shrubbery/BUILD.bazel index 4c7930f16f..314c595d86 100644 --- a/crates/shrubbery/BUILD.bazel +++ b/crates/shrubbery/BUILD.bazel @@ -11,6 +11,7 @@ rust_library( edition = "2024", deps = [ "//crates/exe_zip_maker:exe_zip_maker_lib", + "//crates/wheelmaker:wheelmaker_lib", "//crates/zip_main_maker:zip_main_maker_lib", "//crates/zipper:zipper_lib", ], diff --git a/crates/shrubbery/src/lib.rs b/crates/shrubbery/src/lib.rs index b8ef34a96c..cd17e358ee 100644 --- a/crates/shrubbery/src/lib.rs +++ b/crates/shrubbery/src/lib.rs @@ -11,6 +11,7 @@ use std::process::ExitCode; pub mod subcommands { // keep-sorted start case=no pub const EXE_ZIP_MAKER: &str = "exe_zip_maker"; + pub const WHEELMAKER: &str = "wheelmaker"; pub const ZIP_MAIN_MAKER: &str = "zip_main_maker"; pub const ZIPPER: &str = "zipper"; // keep-sorted end @@ -20,6 +21,7 @@ pub mod subcommands { pub const SUBCOMMANDS: &[&str] = &[ // keep-sorted start case=no subcommands::EXE_ZIP_MAKER, + subcommands::WHEELMAKER, subcommands::ZIP_MAIN_MAKER, subcommands::ZIPPER, // keep-sorted end @@ -64,6 +66,7 @@ where match sub_raw.as_ref() { // keep-sorted start case=no subcommands::EXE_ZIP_MAKER => exe_zip_maker_lib::run_cli(iter), + subcommands::WHEELMAKER => wheelmaker_lib::run_cli(iter), subcommands::ZIP_MAIN_MAKER => zip_main_maker_lib::run_cli(iter), subcommands::ZIPPER => zipper_lib::run_cli(iter), // keep-sorted end diff --git a/crates/wheelmaker/BUILD.bazel b/crates/wheelmaker/BUILD.bazel new file mode 100644 index 0000000000..f918a1af3d --- /dev/null +++ b/crates/wheelmaker/BUILD.bazel @@ -0,0 +1,28 @@ +load("@rules_rust//rust:defs.bzl", "rust_library") +load("//python/private:distribution_filegroup.bzl", "distribution_filegroup") # buildifier: disable=bzl-visibility + +package(default_visibility = ["//:__subpackages__"]) + +licenses(["notice"]) + +rust_library( + name = "wheelmaker_lib", + srcs = ["src/lib.rs"], + edition = "2024", + deps = [ + "@crates//:anyhow", + "@crates//:argfile", + "@crates//:base64", + "@crates//:csv", + "@crates//:lexopt", + "@crates//:pep440_rs", + "@crates//:pep508_rs", + "@crates//:regex", + "@crates//:sha2", + "@crates//:zip", + ], +) + +distribution_filegroup( + name = "distribution", +) diff --git a/crates/wheelmaker/src/lib.rs b/crates/wheelmaker/src/lib.rs new file mode 100644 index 0000000000..414f2e05ae --- /dev/null +++ b/crates/wheelmaker/src/lib.rs @@ -0,0 +1,1008 @@ +//! Library for building deterministic Python `.whl` archives (PEP 427). +//! +//! Mirrors `tools/wheelmaker.py` with two intentional differences stemming from its pure-Rust +//! dependencies: +//! * Compressed `.whl` archives use `flate2`'s pure-Rust DEFLATE backend rather than C `zlib`, so +//! compressed byte streams (and outer `.whl` file digests) differ while archive entries and +//! `RECORD` SHA-256 digests are identical. +//! * `Requires-Dist` lines parsed through `pep508_rs` normalize distribution names (PEP 503), +//! extra names (PEP 685), and environment markers (algebraic PEP 508 simplification). + +// Errors must be returned, not panicked; see the `rust-lint` config in .bazelrc. +#![deny(clippy::expect_used, clippy::unwrap_used)] + +use std::collections::HashMap; +use std::ffi::OsString; +use std::fs::{self, File}; +use std::io::{BufWriter, Read, Seek, Write}; +use std::path::{Path, PathBuf}; +use std::process::ExitCode; +use std::str::FromStr; + +use anyhow::{Context, Result, bail}; +use base64::Engine as _; +use lexopt::prelude::*; +use regex::Regex; +use sha2::{Digest, Sha256}; +use zip::write::SimpleFileOptions; +use zip::{CompressionMethod, DateTime, System, ZIP64_BYTES_THR, ZipWriter}; + +/// Read/write buffer size when streaming files into the `.whl` archive and SHA-256 hasher. +pub const BLOCK_SIZE: usize = 256 * 1024; + +/// Fixed timestamp for all entries so output is deterministic. This is the earliest MS-DOS +/// timestamp a zip can represent (1980-01-01 00:00:00) and matches `_ZIP_EPOCH` in +/// `tools/wheelmaker.py`. +const FIXED_TIMESTAMP: DateTime = DateTime::DEFAULT; + +/// Permissions `-rwxrwxrwx` with regular file bit (`S_IFREG | 0o777`). +/// +/// Both `pip` and `installer` expect the regular file bit to be set in order for the executable +/// bit to be preserved after extraction: +/// * +/// * +pub const REGULAR_FILE_UNIX_MODE: u32 = 0o100777; + +mod flags { + // keep-sorted start + pub const ABI: &str = "abi"; + pub const BUILD_TAG: &str = "build_tag"; + pub const DATA_FILES: &str = "data_files"; + pub const DESCRIPTION_FILE: &str = "description_file"; + pub const ENTRY_POINTS_FILE: &str = "entry_points_file"; + pub const EXTRA_DISTINFO_FILE: &str = "extra_distinfo_file"; + pub const HELP: &str = "help"; + pub const HELP_SHORT: char = 'h'; + pub const INPUT_FILE: &str = "input_file"; + pub const INPUT_FILE_LIST: &str = "input_file_list"; + pub const METADATA_FILE: &str = "metadata_file"; + pub const NAME: &str = "name"; + pub const NAME_FILE: &str = "name_file"; + pub const NO_COMPRESS: &str = "no_compress"; + pub const OUT: &str = "out"; + pub const PATH_PREFIX: &str = "path_prefix"; + pub const PLATFORM: &str = "platform"; + pub const PYTHON_TAG: &str = "python_tag"; + pub const STABLE_STATUS_FILE: &str = "stable_status_file"; + pub const STRIP_PATH_PREFIX: &str = "strip_path_prefix"; + pub const VERSION: &str = "version"; + pub const VOLATILE_STATUS_FILE: &str = "volatile_status_file"; + // keep-sorted end +} + +/// Usage text for `--help`. `lexopt` does not generate help, so this is maintained by hand. +const USAGE: &str = "\ +Usage: wheelmaker [OPTIONS] --name --version --metadata_file + +Build a deterministic Python wheel (.whl) archive. + +Wheel name, version, and platform: + --name Name of the distribution + --version Version of the distribution + --build_tag Optional build tag for the distribution + --python_tag Python version tag, e.g. 'py2' or 'py3' (default: py3) + --abi Python ABI tag (default: none) + --platform Target platform tag (default: any) + +Output and path rewriting: + --out Override output .whl file path + --no_compress Disable compression of the final archive + --name_file File where the canonical wheel filename is written + --strip_path_prefix Path prefix stripped from input package paths + (repeatable, evaluated in order) + --path_prefix Path prefix prepended to input package paths after + stripping + +Wheel metadata and contents: + --metadata_file Contents of METADATA before appending description + --description_file Path to the package description file + --entry_points_file Path to an entry_points.txt file + --input_file File or directory to include in the wheel (repeatable) + --input_file_list File listing 'package_path;real_path' pairs, one per + line (repeatable) + --extra_distinfo_file Extra file to include in .dist-info/ (repeatable) + --data_files Data file to include in .data/ (repeatable) + +Workspace status stamping: + --volatile_status_file Volatile workspace status file for stamping + --stable_status_file Stable workspace status file for stamping + @ Read newline-delimited arguments from + -h, --help Print this help"; + +/// Normalizes a package name according to the Python Packaging User Guide. +/// +/// See . +pub fn normalize_package_name(name: &str) -> Result { + let re = Regex::new(r"[-_.]+")?; + Ok(re.replace_all(name, "-").to_lowercase()) +} + +/// Escapes the distribution name component of a wheel filename. +/// +/// See . +pub fn escape_filename_distribution_name(name: &str) -> Result { + Ok(normalize_package_name(name)?.replace('-', "_")) +} + +/// Normalizes `version` according to PEP 440, with fallback for `{PLACEHOLDER}` stamps. +/// +/// If there is a placeholder in braces, such as `{BUILD_TIMESTAMP}`, replaces it with `0`. Such +/// placeholders can be used with stamping, in which case they would have been resolved already; +/// if they have not, this is an unstamped build that still needs a valid PEP 440 version. When +/// replacements are made, the original version string (sanitized to dot-separated alphanumerics) +/// is appended as a local version segment so the placeholder remains visible. +/// +/// If that still does not produce a valid PEP 440 version, falls back to `0+`. +pub fn normalize_pep440(version: &str) -> Result { + if let Ok(ver) = pep440_rs::Version::from_str(version.trim()) { + return Ok(ver.to_string()); + } + + let local_sanitize_re = Regex::new(r"[^a-z0-9]+")?; + let brace_placeholder_re = Regex::new(r"\{\w+\}")?; + + let lowered = version.to_lowercase(); + let sanitized = local_sanitize_re + .replace_all(&lowered, ".") + .trim_matches('.') + .to_string(); + let substituted = brace_placeholder_re.replace_all(version, "0"); + let delimiter = if substituted.contains('+') { "." } else { "+" }; + let candidate = format!("{substituted}{delimiter}{sanitized}"); + if let Ok(ver) = pep440_rs::Version::from_str(&candidate) { + return Ok(ver.to_string()); + } + + let fallback = format!("0+{sanitized}"); + pep440_rs::Version::from_str(&fallback) + .map(|ver| ver.to_string()) + .with_context(|| format!("invalid PEP 440 version: {version:?}")) +} + +/// Returns the archive-root-relative path (using `/` separators) for `name`. +/// +/// Prefixes in `strip_path_prefixes` are checked in order and only the first match is stripped, +/// after which `add_path_prefix` is prepended. Paths already starting with `distribution_prefix` +/// (such as `.dist-info/` and `.data/` entries) are returned without prefix rewriting. +pub fn arcname_from( + name: &str, + distribution_prefix: &str, + strip_path_prefixes: &[String], + add_path_prefix: &str, +) -> String { + // Always use Unix path separators inside zip archives. + let normalized_arcname = name.replace('\\', "/"); + // Don't manipulate filenames in the .dist-info or .data directories. + if !distribution_prefix.is_empty() && normalized_arcname.starts_with(distribution_prefix) { + return normalized_arcname; + } + let normalized_prefix = add_path_prefix.replace('\\', "/"); + for prefix in strip_path_prefixes { + if let Some(stripped) = normalized_arcname.strip_prefix(prefix.as_str()) { + return format!("{normalized_prefix}{stripped}"); + } + } + format!("{normalized_prefix}{normalized_arcname}") +} + +/// Formats a raw SHA-256 digest as `sha256=` per PEP 376 (`RECORD`). +/// +/// See (`urlsafe_b64encode(digest)` with trailing `=` +/// removed). +pub fn serialize_digest(sha256_bytes: &[u8]) -> String { + format!( + "sha256={}", + base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(sha256_bytes) + ) +} + +/// Collects `(package_path, real_path)` pairs into a map keyed by `package_path` (later entries +/// win on duplicate archive destinations, matching `tools/wheelmaker.py`). +/// +/// Keys (`package_path`) are relative to the wheel root before prefix rewriting; values +/// (`real_path`) are filesystem paths relative to CWD or absolute. +pub fn get_files_to_package(input_files: &[(String, PathBuf)]) -> HashMap { + let mut files = HashMap::with_capacity(input_files.len()); + for (package_path, real_path) in input_files { + files.insert(package_path.clone(), real_path.clone()); + } + files +} + +fn format_requirement(req: &pep508_rs::Requirement) -> String { + let mut out = format!("Requires-Dist: {}", req.name); + if !req.extras.is_empty() { + let mut extras: Vec = req.extras.iter().map(ToString::to_string).collect(); + extras.sort_unstable(); + extras.dedup(); + out.push('['); + out.push_str(&extras.join(",")); + out.push(']'); + } + let is_url = match &req.version_or_url { + Some(pep508_rs::VersionOrUrl::VersionSpecifier(specs)) => { + let mut spec_strs: Vec = specs.iter().map(ToString::to_string).collect(); + spec_strs.sort_unstable(); + spec_strs.dedup(); + out.push_str(&spec_strs.join(",")); + false + } + Some(pep508_rs::VersionOrUrl::Url(url)) => { + out.push_str(" @ "); + if let Some(given) = url.given() { + out.push_str(given); + } else { + out.push_str(&url.to_string()); + } + true + } + None => false, + }; + if let Some(marker) = req.marker.contents() { + // PEP 508 requires whitespace before `;` after a URL so `;` is not parsed as part of the + // URI itself. + let sep = if is_url { " ; " } else { "; " }; + out.push_str(sep); + out.push_str(&marker.to_string()); + } + out +} + +/// Formats a PEP 508 requirement string and optional extra marker expression into a `Requires-Dist` +/// metadata line. +/// +/// Uses `pep508_rs`, which normalizes package names (PEP 503), extra names (PEP 685), and +/// environment markers. +pub fn get_new_requirement_line(reqs_text: &str, extra: &str) -> Result { + let mut req = pep508_rs::Requirement::::from_str(reqs_text.trim()) + .with_context(|| format!("parsing requirement {reqs_text:?}"))?; + let extra_trimmed = extra.trim(); + if !extra_trimmed.is_empty() { + let extra_tree = pep508_rs::MarkerTree::from_str(extra_trimmed) + .with_context(|| format!("parsing extra marker {extra_trimmed:?}"))?; + req.marker.and(extra_tree); + } + Ok(format_requirement(&req)) +} + +/// Resolves `{KEY}` workspace status placeholders in `argument` using `KEY VALUE` lines read from +/// Bazel status files. +pub fn resolve_stamp_with_lines(argument: &str, status_lines: &[String]) -> String { + let mut resolved = argument.to_string(); + for line in status_lines { + if line.is_empty() { + continue; + } + let (key, value) = line.split_once(' ').unwrap_or((line.as_str(), "")); + let stamp = format!("{{{key}}}"); + resolved = resolved.replace(&stamp, value); + } + resolved +} + +fn read_text_universal_newlines(path: &Path) -> Result { + let raw = fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?; + Ok(raw.replace("\r\n", "\n")) +} + +/// Expands `Requires-Dist:` lines in `metadata` (both inline requirements with `;` markers and +/// `@file` requirement-file directives). +pub fn expand_metadata_requires(metadata: &str) -> Result { + let normalized = metadata.replace("\r\n", "\n"); + let mut out = String::with_capacity(normalized.len()); + + for raw_line in normalized.split_inclusive('\n') { + let (meta_line, line_ending) = match raw_line.strip_suffix('\n') { + Some(line) => (line, "\n"), + None => (raw_line, ""), + }; + + let Some(after_prefix) = meta_line.strip_prefix("Requires-Dist: ") else { + out.push_str(raw_line); + continue; + }; + + let Some(after_at) = after_prefix.strip_prefix('@') else { + // Normal inline requirement: only re-format when a `;` marker/extra is present, + // matching `tools/wheelmaker.py`. + let Some((package, extra)) = after_prefix.rsplit_once(';') else { + out.push_str(raw_line); + continue; + }; + let formatted = get_new_requirement_line(package, extra.trim()) + .with_context(|| format!("in metadata line {meta_line:?}"))?; + out.push_str(&formatted); + out.push_str(line_ending); + continue; + }; + + // Requirement directive referring to an external requirements file (`@path[; extra]`). + let (file_part, extra) = match after_at.split_once(';') { + Some((f, e)) => (f, e.trim()), + None => (after_at, ""), + }; + let req_file_text = read_text_universal_newlines(Path::new(file_part))?; + let mut reqs = Vec::new(); + for reqs_line in req_file_text.lines() { + let reqs_text = reqs_line.trim(); + if reqs_text.is_empty() || reqs_text.starts_with('#') || reqs_text.starts_with('-') { + continue; + } + // Strip inline comments. + let reqs_text = match reqs_text.split_once('#') { + Some((before_comment, _)) => before_comment, + None => reqs_text, + }; + let formatted = get_new_requirement_line(reqs_text, extra) + .with_context(|| format!("in requirements file {file_part}"))?; + reqs.push(formatted); + } + + // If the referenced requirements file has no requirements, drop the directive line + // (including its trailing newline) entirely. + if !reqs.is_empty() { + out.push_str(&reqs.join("\n")); + out.push_str(line_ending); + } + } + + Ok(out) +} + +fn create_parent_dir(path: &Path) -> Result<()> { + if let Some(parent) = path.parent() + && !parent.as_os_str().is_empty() + { + fs::create_dir_all(parent) + .with_context(|| format!("creating directory {}", parent.display()))?; + } + Ok(()) +} + +/// Collects `--input_file` and `--input_file_list` entries into archive-path-sorted +/// `(package_path, real_path)` pairs. +/// +/// Each `package_path` is relative to the wheel root before prefix rewriting; each `real_path` is +/// relative to CWD or absolute. +fn collect_sorted_inputs(options: &Options) -> Result> { + let mut input_files = options.input_file.clone(); + for list_path in &options.input_file_list { + let content = read_text_universal_newlines(list_path)?; + for line in content.lines() { + if line.is_empty() { + continue; + } + let Some((pkg, real)) = line.split_once(';') else { + bail!( + "invalid line in input_file_list {} \ + (expected 'package_path;real_path'): {line:?}", + list_path.display() + ); + }; + input_files.push((pkg.to_string(), PathBuf::from(real))); + } + } + let mut sorted_files: Vec<(String, PathBuf)> = + get_files_to_package(&input_files).into_iter().collect(); + sorted_files.sort_unstable_by(|a, b| a.0.cmp(&b.0)); + Ok(sorted_files) +} + +/// Resolves `{KEY}` workspace status stamps in `options.name` and `options.version` when both +/// volatile and stable status files are provided (matching `tools/wheelmaker.py`). +fn resolve_name_and_version(options: &Options) -> Result<(String, String)> { + let (Some(volatile_path), Some(stable_path)) = + (&options.volatile_status_file, &options.stable_status_file) + else { + return Ok((options.name.clone(), options.version.clone())); + }; + let volatile_text = read_text_universal_newlines(volatile_path)?; + let stable_text = read_text_universal_newlines(stable_path)?; + let status_lines: Vec = volatile_text + .lines() + .chain(stable_text.lines()) + .map(ToString::to_string) + .collect(); + Ok(( + resolve_stamp_with_lines(&options.name, &status_lines), + resolve_stamp_with_lines(&options.version, &status_lines), + )) +} + +/// Builds the `.whl` archive and optional `--name_file` according to `options`. +pub fn build_wheel(options: &Options) -> Result<()> { + let sorted_files = collect_sorted_inputs(options)?; + let (name, version) = resolve_name_and_version(options)?; + let maker = WheelMaker::new(&name, &version, options)?; + + let out_path = maker.filename(); + create_parent_dir(&out_path)?; + let out_file = BufWriter::with_capacity( + BLOCK_SIZE, + File::create(&out_path) + .with_context(|| format!("creating wheel {}", out_path.display()))?, + ); + let mut whl = maker.open_whlfile(out_file); + + for (package_filename, real_filename) in &sorted_files { + whl.add_file(package_filename, real_filename)?; + } + + let wheel_contents = maker.wheelfile_contents(); + whl.add_string(&maker.distinfo_path("WHEEL"), wheel_contents.as_bytes())?; + + let description = match &options.description_file { + Some(desc_path) => Some(read_text_universal_newlines(desc_path)?), + None => None, + }; + + let raw_metadata = read_text_universal_newlines(&options.metadata_file)?; + let expanded_metadata = expand_metadata_requires(&raw_metadata)?; + let final_metadata = maker.format_metadata(&expanded_metadata, description.as_deref())?; + whl.add_string(&maker.distinfo_path("METADATA"), final_metadata.as_bytes())?; + + if let Some(ref ep_path) = options.entry_points_file { + whl.add_file(&maker.distinfo_path("entry_points.txt"), ep_path)?; + } + + // Sort data and extra dist-info files for reproducible order in the archive. + let mut data_files = options.data_files.clone(); + data_files.sort_unstable(); + for (filename, real_path) in &data_files { + whl.add_file(&maker.data_path(filename), real_path)?; + } + + let mut extra_distinfo_file = options.extra_distinfo_file.clone(); + extra_distinfo_file.sort_unstable(); + for (filename, real_path) in &extra_distinfo_file { + whl.add_file(&maker.distinfo_path(filename), real_path)?; + } + + whl.add_recordfile()?; + whl.finish() + .with_context(|| format!("finalizing wheel {}", out_path.display()))?; + + // Since stamping may change the target name of the wheel, write the canonical name (with + // stamps resolved) to `--name_file` so downstream consumers can determine the stamped name. + if let Some(ref name_file_path) = options.name_file { + create_parent_dir(name_file_path)?; + fs::write(name_file_path, maker.wheelname()) + .with_context(|| format!("writing name_file {}", name_file_path.display()))?; + } + + Ok(()) +} + +fn parse_target_path_pair(raw: &str) -> std::result::Result<(String, PathBuf), String> { + let (target, real_path) = raw + .split_once(';') + .ok_or_else(|| format!("expected 'target;real_path' pair, got {raw:?}"))?; + Ok((target.to_string(), PathBuf::from(real_path))) +} + +/// Parses command-line arguments (excluding `argv[0]` and subcommand name) into [`Cli`]. +pub fn parse_args(args: I) -> Result +where + I: IntoIterator, + T: Into, +{ + let expanded = argfile::expand_args_from( + args.into_iter().map(Into::into), + argfile::parse_fromfile, + argfile::PREFIX, + ) + .context("reading @flagfile")?; + + let mut name: Option = None; + let mut version: Option = None; + let mut build_tag = String::new(); + let mut python_tag = "py3".to_string(); + let mut abi = "none".to_string(); + let mut platform = "any".to_string(); + let mut out: Option = None; + let mut no_compress = false; + let mut name_file: Option = None; + let mut strip_path_prefixes: Vec = Vec::new(); + let mut path_prefix = String::new(); + let mut metadata_file: Option = None; + let mut description_file: Option = None; + let mut entry_points_file: Option = None; + let mut input_file: Vec<(String, PathBuf)> = Vec::new(); + let mut input_file_list: Vec = Vec::new(); + let mut extra_distinfo_file: Vec<(String, PathBuf)> = Vec::new(); + let mut data_files: Vec<(String, PathBuf)> = Vec::new(); + let mut volatile_status_file: Option = None; + let mut stable_status_file: Option = None; + + let mut parser = lexopt::Parser::from_args(expanded); + while let Some(arg) = parser.next()? { + match arg { + Short(flags::HELP_SHORT) | Long(flags::HELP) => return Ok(Cli::Help), + Long(flags::NAME) => { + name = Some(parser.value()?.string()?); + } + Long(flags::VERSION) => { + version = Some(parser.value()?.string()?); + } + Long(flags::BUILD_TAG) => { + build_tag = parser.value()?.string()?; + } + Long(flags::PYTHON_TAG) => { + python_tag = parser.value()?.string()?; + } + Long(flags::ABI) => { + abi = parser.value()?.string()?; + } + Long(flags::PLATFORM) => { + platform = parser.value()?.string()?; + } + Long(flags::OUT) => { + out = Some(PathBuf::from(parser.value()?)); + } + Long(flags::NO_COMPRESS) => { + no_compress = true; + } + Long(flags::NAME_FILE) => { + name_file = Some(PathBuf::from(parser.value()?)); + } + Long(flags::STRIP_PATH_PREFIX) => { + strip_path_prefixes.push(parser.value()?.string()?); + } + Long(flags::PATH_PREFIX) => { + path_prefix = parser.value()?.string()?; + } + Long(flags::METADATA_FILE) => { + metadata_file = Some(PathBuf::from(parser.value()?)); + } + Long(flags::DESCRIPTION_FILE) => { + description_file = Some(PathBuf::from(parser.value()?)); + } + Long(flags::ENTRY_POINTS_FILE) => { + entry_points_file = Some(PathBuf::from(parser.value()?)); + } + Long(flags::INPUT_FILE) => { + input_file.push(parser.value()?.parse_with(parse_target_path_pair)?); + } + Long(flags::INPUT_FILE_LIST) => { + input_file_list.push(PathBuf::from(parser.value()?)); + } + Long(flags::EXTRA_DISTINFO_FILE) => { + extra_distinfo_file.push(parser.value()?.parse_with(parse_target_path_pair)?); + } + Long(flags::DATA_FILES) => { + data_files.push(parser.value()?.parse_with(parse_target_path_pair)?); + } + Long(flags::VOLATILE_STATUS_FILE) => { + volatile_status_file = Some(PathBuf::from(parser.value()?)); + } + Long(flags::STABLE_STATUS_FILE) => { + stable_status_file = Some(PathBuf::from(parser.value()?)); + } + _ => bail!("{}", arg.unexpected()), + } + } + + let name = name.with_context(|| format!("missing required argument: --{}", flags::NAME))?; + let version = + version.with_context(|| format!("missing required argument: --{}", flags::VERSION))?; + let metadata_file = metadata_file + .with_context(|| format!("missing required argument: --{}", flags::METADATA_FILE))?; + + Ok(Cli::Run(Box::new(Options { + name, + version, + build_tag, + python_tag, + abi, + platform, + out, + no_compress, + name_file, + strip_path_prefixes, + path_prefix, + metadata_file, + description_file, + entry_points_file, + input_file, + input_file_list, + extra_distinfo_file, + data_files, + volatile_status_file, + stable_status_file, + }))) +} + +/// Parses CLI arguments (excluding `argv[0]` and subcommand name), builds the wheel, and returns +/// the process exit code. +pub fn run_cli(args: I) -> ExitCode +where + I: IntoIterator, + T: Into, +{ + let options = match parse_args(args) { + Ok(Cli::Help) => { + println!("{USAGE}"); + return ExitCode::SUCCESS; + } + Ok(Cli::Run(opts)) => opts, + Err(err) => { + eprintln!("wheelmaker: error: {err:#}"); + return ExitCode::FAILURE; + } + }; + if let Err(err) = build_wheel(&options) { + eprintln!("wheelmaker: error: {err:#}"); + return ExitCode::FAILURE; + } + ExitCode::SUCCESS +} + +/// Low-level `.whl` zip archive writer that records `(path, sha256, size)` entries for `RECORD`, +/// mirroring `_WhlFile` in `tools/wheelmaker.py`. +pub struct WhlFile { + zip: ZipWriter, + compress: bool, + distribution_prefix: String, + strip_path_prefixes: Vec, + add_path_prefix: String, + buf: Vec, + /// Recorded `(arcname, digest, size)` tuples where `arcname` is relative to the wheel root. + record: Vec<(String, String, String)>, +} + +impl WhlFile { + /// Creates a new `.whl` archive writer over `writer`. + pub fn new( + writer: W, + distribution_prefix: &str, + strip_path_prefixes: Vec, + add_path_prefix: &str, + compress: bool, + ) -> Self { + Self { + zip: ZipWriter::new(writer), + compress, + distribution_prefix: distribution_prefix.to_string(), + strip_path_prefixes, + add_path_prefix: add_path_prefix.to_string(), + buf: vec![0u8; BLOCK_SIZE], + record: Vec::new(), + } + } + + fn distinfo_path(&self, basename: &str) -> String { + format!("{}.dist-info/{basename}", self.distribution_prefix) + } + + fn clean_zip_arcname(filename: &str) -> &str { + // Strip leading path separators to mirror `ZipInfo.from_file` / `_WhlFile._zipinfo`. + filename.trim_start_matches(['/', '\\']) + } + + fn file_options(&self, size: u64) -> SimpleFileOptions { + let method = if self.compress { + CompressionMethod::Deflated + } else { + CompressionMethod::Stored + }; + // Use `System::Unix` (`create_system = 3`) so `zip` preserves `unix_permissions` on + // Windows too instead of synthesizing MS-DOS attributes. + SimpleFileOptions::default() + .compression_method(method) + .last_modified_time(FIXED_TIMESTAMP) + .system(System::Unix) + .unix_permissions(REGULAR_FILE_UNIX_MODE) + .large_file(size >= ZIP64_BYTES_THR) + } + + /// Copies `real_filename` (a file or directory, relative to CWD or absolute) into the wheel + /// under `package_filename` (relative to the archive root before prefix rewriting). + pub fn add_file(&mut self, package_filename: &str, real_filename: &Path) -> Result<()> { + if real_filename.is_dir() { + let mut entries = Vec::new(); + for entry in fs::read_dir(real_filename) + .with_context(|| format!("reading directory {}", real_filename.display()))? + { + let entry = entry.with_context(|| { + format!("reading directory entry in {}", real_filename.display()) + })?; + let Ok(file_name) = entry.file_name().into_string() else { + bail!( + "non-UTF-8 filename in input directory {}: {:?}", + real_filename.display(), + entry.file_name() + ); + }; + entries.push((file_name, entry.path())); + } + entries.sort_by(|a, b| a.0.cmp(&b.0)); + for (file_name, path) in entries { + let child_pkg = format!("{package_filename}/{file_name}"); + self.add_file(&child_pkg, &path)?; + } + return Ok(()); + } + + let arcname = arcname_from( + package_filename, + &self.distribution_prefix, + &self.strip_path_prefixes, + &self.add_path_prefix, + ); + let zip_arcname = Self::clean_zip_arcname(&arcname); + + let mut src = File::open(real_filename) + .with_context(|| format!("opening input file {}", real_filename.display()))?; + let initial_len = src + .metadata() + .with_context(|| format!("reading metadata for {}", real_filename.display()))? + .len(); + let opts = self.file_options(initial_len); + self.zip + .start_file(zip_arcname, opts) + .with_context(|| format!("starting zip entry {zip_arcname}"))?; + + let mut sha = Sha256::new(); + let mut size: u64 = 0; + loop { + let n = src + .read(&mut self.buf) + .with_context(|| format!("reading input file {}", real_filename.display()))?; + if n == 0 { + break; + } + self.zip + .write_all(&self.buf[..n]) + .with_context(|| format!("writing zip entry {zip_arcname}"))?; + sha.update(&self.buf[..n]); + size += n as u64; + } + + let digest = serialize_digest(&sha.finalize()); + self.record + .push((zip_arcname.to_string(), digest, size.to_string())); + Ok(()) + } + + /// Writes in-memory `contents` as `filename` (relative to the archive root) and records its + /// SHA-256 digest and byte length. + pub fn add_string(&mut self, filename: &str, contents: &[u8]) -> Result<()> { + let zip_arcname = Self::clean_zip_arcname(filename); + let opts = self.file_options(contents.len() as u64); + self.zip + .start_file(zip_arcname, opts) + .with_context(|| format!("starting zip entry {zip_arcname}"))?; + self.zip + .write_all(contents) + .with_context(|| format!("writing zip entry {zip_arcname}"))?; + + let mut sha = Sha256::new(); + sha.update(contents); + let digest = serialize_digest(&sha.finalize()); + self.record + .push((zip_arcname.to_string(), digest, contents.len().to_string())); + Ok(()) + } + + /// Formats and writes `/RECORD` using minimal CSV quoting, returning the written + /// `RECORD` text. + pub fn add_recordfile(&mut self) -> Result { + let record_path = self.distinfo_path("RECORD"); + let mut wtr = csv::WriterBuilder::new() + .has_headers(false) + .terminator(csv::Terminator::Any(b'\n')) + .quote_style(csv::QuoteStyle::Necessary) + .from_writer(Vec::new()); + for (fname, digest, size) in &self.record { + wtr.write_record([fname.as_str(), digest.as_str(), size.as_str()]) + .context("formatting RECORD entry as CSV")?; + } + wtr.write_record([Self::clean_zip_arcname(&record_path), "", ""]) + .context("formatting RECORD self-entry as CSV")?; + let bytes = wtr.into_inner().context("flushing RECORD CSV buffer")?; + let contents = String::from_utf8(bytes).context("RECORD CSV was not valid UTF-8")?; + self.add_string(&record_path, contents.as_bytes())?; + Ok(contents) + } + + /// Finalizes the underlying zip archive and flushes `W`. + pub fn finish(self) -> Result { + let mut inner = self.zip.finish().context("writing zip central directory")?; + inner.flush().context("flushing zip writer")?; + Ok(inner) + } +} + +/// High-level wheel builder mirroring `WheelMaker` in `tools/wheelmaker.py`. +pub struct WheelMaker { + name: String, + version: String, + build_tag: String, + python_tag: String, + abi: String, + platform: String, + /// Explicit output `.whl` path relative to CWD or absolute, if `--out` was given. + outfile: Option, + strip_path_prefixes: Vec, + add_path_prefix: String, + compress: bool, + wheelname_fragment_distribution_name: String, + distribution_prefix: String, +} + +impl WheelMaker { + /// Creates a `WheelMaker` with resolved `name` and `version` (after any workspace status + /// stamping) and the remaining wheel settings from `options`. + pub fn new(name: &str, version: &str, options: &Options) -> Result { + let norm_version = normalize_pep440(version)?; + let wheelname_fragment_distribution_name = escape_filename_distribution_name(name)?; + let distribution_prefix = format!("{wheelname_fragment_distribution_name}-{norm_version}"); + Ok(Self { + name: name.to_string(), + version: norm_version, + build_tag: options.build_tag.clone(), + python_tag: options.python_tag.clone(), + abi: options.abi.clone(), + platform: options.platform.clone(), + outfile: options.out.clone(), + strip_path_prefixes: options.strip_path_prefixes.clone(), + add_path_prefix: options.path_prefix.clone(), + compress: !options.no_compress, + wheelname_fragment_distribution_name, + distribution_prefix, + }) + } + + /// Returns the canonical PEP 427 wheel filename + /// (`-[-]---.whl`). + pub fn wheelname(&self) -> String { + let mut components = vec![ + self.wheelname_fragment_distribution_name.as_str(), + self.version.as_str(), + ]; + if !self.build_tag.is_empty() { + components.push(self.build_tag.as_str()); + } + components.extend([ + self.python_tag.as_str(), + self.abi.as_str(), + self.platform.as_str(), + ]); + format!("{}.whl", components.join("-")) + } + + /// Returns the output `.whl` path (either `--out` or [`Self::wheelname`] relative to CWD). + pub fn filename(&self) -> PathBuf { + if let Some(ref out) = self.outfile { + out.clone() + } else { + PathBuf::from(self.wheelname()) + } + } + + /// Returns the compatibility tags written to `/WHEEL`. + pub fn disttags(&self) -> Vec { + vec![format!( + "{}-{}-{}", + self.python_tag, self.abi, self.platform + )] + } + + /// Returns `.dist-info/` relative to the archive root. + pub fn distinfo_path(&self, basename: &str) -> String { + format!("{}.dist-info/{basename}", self.distribution_prefix) + } + + /// Returns `.data/` relative to the archive root. + pub fn data_path(&self, basename: &str) -> String { + format!("{}.data/{basename}", self.distribution_prefix) + } + + /// Formats the `/WHEEL` metadata file contents. + pub fn wheelfile_contents(&self) -> String { + // TODO(pstradomski): Support non-purelib wheels. + let purelib = if self.platform == "any" { + "true" + } else { + "false" + }; + let mut contents = format!( + "Wheel-Version: 1.0\nGenerator: bazel-wheelmaker 1.0\nRoot-Is-Purelib: {purelib}\n" + ); + for tag in self.disttags() { + contents.push_str(&format!("Tag: {tag}\n")); + } + contents + } + + /// Formats the `/METADATA` contents per PEP 566 / Core Metadata. + /// + /// See and + /// . + pub fn format_metadata(&self, metadata: &str, description: Option<&str>) -> Result { + let name_re = Regex::new(r"(?m)^Name: .*$")?; + let replacement = format!("Name: {}", self.name); + let mut out = name_re + .replace_all(metadata, regex::NoExpand(&replacement)) + .into_owned(); + out.push_str(&format!("Version: {}\n\n", self.version)); + // setuptools inserts `UNKNOWN` as the description when none is provided. + match description { + Some(desc) if !desc.is_empty() => out.push_str(desc), + _ => out.push_str("UNKNOWN"), + } + out.push('\n'); + Ok(out) + } + + /// Opens a [`WhlFile`] configured with this wheel's prefix and compression settings. + pub fn open_whlfile(&self, writer: W) -> WhlFile { + WhlFile::new( + writer, + &self.distribution_prefix, + self.strip_path_prefixes.clone(), + &self.add_path_prefix, + self.compress, + ) + } +} + +/// Result of parsing the command line. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Cli { + /// `--help` was requested. + Help, + /// Build a wheel archive with the given options. + Run(Box), +} + +/// Parsed command-line options for `wheelmaker`. +/// +/// All `PathBuf` fields hold filesystem paths relative to the current working directory or +/// absolute; archive destination strings in `(String, PathBuf)` pairs are relative to the archive +/// root, `.dist-info/`, or `.data/` respectively. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Options { + /// Distribution name (may contain `{KEY}` stamp placeholders). + pub name: String, + /// Distribution version string (may contain `{KEY}` stamp placeholders). + pub version: String, + /// Optional PEP 427 build tag. + pub build_tag: String, + /// Python implementation/version tag (e.g. `py3`, `cp311`). + pub python_tag: String, + /// Python ABI tag (e.g. `none`, `abi3`). + pub abi: String, + /// Target platform tag (e.g. `any`, `manylinux2014_x86_64`). + pub platform: String, + /// Optional output `.whl` file path, relative to CWD or absolute. + pub out: Option, + /// When `true`, store archive entries uncompressed (`ZIP_STORED`). + pub no_compress: bool, + /// Optional output file where the canonical wheel filename is written, relative to CWD or + /// absolute. + pub name_file: Option, + /// Path prefixes stripped in order from archive entry paths. + pub strip_path_prefixes: Vec, + /// Path prefix prepended to archive entry paths after stripping. + pub path_prefix: String, + /// Path to the pre-formatted `METADATA` header file, relative to CWD or absolute. + pub metadata_file: PathBuf, + /// Optional path to the package description file, relative to CWD or absolute. + pub description_file: Option, + /// Optional path to `entry_points.txt`, relative to CWD or absolute. + pub entry_points_file: Option, + /// `(archive_path, filesystem_path)` pairs added to the wheel root. + pub input_file: Vec<(String, PathBuf)>, + /// Paths to files containing newline-delimited `archive_path;filesystem_path` pairs, relative + /// to CWD or absolute. + pub input_file_list: Vec, + /// `(distinfo_rel_path, filesystem_path)` pairs added under `/`. + pub extra_distinfo_file: Vec<(String, PathBuf)>, + /// `(data_rel_path, filesystem_path)` pairs added under `/`. + pub data_files: Vec<(String, PathBuf)>, + /// Optional volatile Bazel workspace status file, relative to CWD or absolute. + pub volatile_status_file: Option, + /// Optional stable Bazel workspace status file, relative to CWD or absolute. + pub stable_status_file: Option, +} diff --git a/examples/wheel/BUILD.bazel b/examples/wheel/BUILD.bazel index 94ad86f885..c28b61a6be 100644 --- a/examples/wheel/BUILD.bazel +++ b/examples/wheel/BUILD.bazel @@ -443,6 +443,20 @@ py_wheel( version = "0.0.1", ) +_PYTHON_ENV = {"WHEELMAKER_IMPL": "python"} + +_BZLMOD_ENV = select({ + "//python/private/toolchains:is_need_shrubbery_enabled": { + "WHEELMAKER_IMPL": "rust", + }, + "//conditions:default": _PYTHON_ENV, +}) + +# In WORKSPACE mode, rules_rust is a stub and @rules_python_tools is not +# registered, so py_wheel always falls back to the Python wheelmaker even when +# is_need_shrubbery_enabled matches. +_WHEELMAKER_ENV = _BZLMOD_ENV if BZLMOD_ENABLED else _PYTHON_ENV + py_test( name = "wheel_test", srcs = ["wheel_test.py"], @@ -466,6 +480,7 @@ py_test( ":requires_files", ":use_rule_with_dir_in_outs", ], + env = _WHEELMAKER_ENV, deps = [ "//python/runfiles", ], @@ -488,10 +503,12 @@ py_test( ":pypiserver", ], env = { - "PUBLISH_PATH": "$(location :minimal_with_py_library.publish)", - "SERVER_PATH": "$(location :pypiserver)", + # keep-sorted start + "PUBLISH_PATH": "$(rootpath :minimal_with_py_library.publish)", + "SERVER_PATH": "$(rootpath :pypiserver)", "WHEEL_PATH": "$(rootpath :minimal_with_py_library)", - }, + # keep-sorted end + } | _WHEELMAKER_ENV, target_compatible_with = select({ "@platforms//os:linux": [], "@platforms//os:macos": [], diff --git a/examples/wheel/test_publish.py b/examples/wheel/test_publish.py index 4bc657c52e..fa8251664b 100644 --- a/examples/wheel/test_publish.py +++ b/examples/wheel/test_publish.py @@ -9,6 +9,16 @@ from urllib.error import URLError from urllib.request import urlopen +_WHEELMAKER_IMPL = os.environ["WHEELMAKER_IMPL"] +# Rust wheelmaker (flate2) and Python wheelmaker.py (zlib) emit deterministic +# but distinct RFC 1951 DEFLATE streams. +_EXPECTED_WHEEL_SHA256 = { + # keep-sorted start + "python": "ef5afd9f6c3ff569ef7e5b2799d3a2ec9675d029414f341e0abd7254d6b9a25d", + "rust": "7b0ddefcee45535ba6808761e540332fe5488deb53ff37f5006416a9fd1b48ef", + # keep-sorted end +} + def find_free_port(): with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: @@ -94,9 +104,10 @@ def test_upload_and_query_simple_api(self): ) # Then I should be able to get its contents + want_sha256 = _EXPECTED_WHEEL_SHA256[_WHEELMAKER_IMPL] with urlopen(self.url + "/example-minimal-library/") as response: got_content = response.read().decode("utf-8") - want_content = """ + want_content = f""" @@ -106,7 +117,7 @@ def test_upload_and_query_simple_api(self):

Links for example-minimal-library

- example_minimal_library-0.0.1-py3-none-any.whl
+ example_minimal_library-0.0.1-py3-none-any.whl
""" self.assertEqual( diff --git a/examples/wheel/wheel_test.py b/examples/wheel/wheel_test.py index 8bfd87c01e..b93d09e0a7 100644 --- a/examples/wheel/wheel_test.py +++ b/examples/wheel/wheel_test.py @@ -22,6 +22,8 @@ from python.runfiles import runfiles +_WHEELMAKER_IMPL = os.environ["WHEELMAKER_IMPL"] + class WheelTest(unittest.TestCase): maxDiff = None @@ -46,7 +48,7 @@ def _get_path(self, filename): else: return path - def assertFileSha256Equal(self, filename, want): + def assertFileSha256Equal(self, filename: str, want: dict[str, str]) -> None: # On Windows, Git checkouts use CRLF line endings for source text files # by default, altering the raw SHA-256 digest of built wheel archives. # Structure and reproducible metadata assertions below still validate @@ -60,7 +62,7 @@ def assertFileSha256Equal(self, filename, want): if not buf: break hash.update(buf) - self.assertEqual(want, hash.hexdigest()) + self.assertEqual(want[_WHEELMAKER_IMPL], hash.hexdigest()) def assertAllEntriesHasReproducibleMetadata(self, zf): for zinfo in zf.infolist(): @@ -91,8 +93,16 @@ def test_py_library_wheel(self): "example_minimal_library-0.0.1.dist-info/RECORD", ], ) + # Rust wheelmaker (flate2) and Python wheelmaker.py (zlib) emit + # deterministic but distinct RFC 1951 DEFLATE streams. self.assertFileSha256Equal( - filename, "ef5afd9f6c3ff569ef7e5b2799d3a2ec9675d029414f341e0abd7254d6b9a25d" + filename, + { + # keep-sorted start + "python": "ef5afd9f6c3ff569ef7e5b2799d3a2ec9675d029414f341e0abd7254d6b9a25d", + "rust": "7b0ddefcee45535ba6808761e540332fe5488deb53ff37f5006416a9fd1b48ef", + # keep-sorted end + }, ) def test_py_package_wheel(self): @@ -117,7 +127,13 @@ def test_py_package_wheel(self): ], ) self.assertFileSha256Equal( - filename, "7322902ab63fd702afb9730843496637058b5d7449208c624875d06d191d386e" + filename, + { + # keep-sorted start + "python": "7322902ab63fd702afb9730843496637058b5d7449208c624875d06d191d386e", + "rust": "01eacc04389891449feadac17a3fabcb8258398518327671c9f031a760293db0", + # keep-sorted end + }, ) def test_customized_wheel(self): @@ -213,7 +229,13 @@ def test_customized_wheel(self): second = second.main:s""", ) self.assertFileSha256Equal( - filename, "6d08fbb30864cee89396e7857c910c92bec56b6586d40a64b796b4812af15fbf" + filename, + { + # keep-sorted start + "python": "6d08fbb30864cee89396e7857c910c92bec56b6586d40a64b796b4812af15fbf", + "rust": "1d34e7c704448673a6a4458b887f4e70f6874a7646778828c079e0ac2e454db1", + # keep-sorted end + }, ) def test_filename_escaping(self): @@ -285,7 +307,13 @@ def test_custom_package_root_wheel(self): for line in record_contents.splitlines(): self.assertFalse(line.startswith("/")) self.assertFileSha256Equal( - filename, "0b5a35251ad35fd9e14f3f7e77993f59a7341268f24fb0a255b403cee60d429e" + filename, + { + # keep-sorted start + "python": "0b5a35251ad35fd9e14f3f7e77993f59a7341268f24fb0a255b403cee60d429e", + "rust": "1b45e76f5618d7125b8a0ea0fd4de841c250575a73869fb67293d95325f763b8", + # keep-sorted end + }, ) def test_custom_package_root_multi_prefix_wheel(self): @@ -319,7 +347,13 @@ def test_custom_package_root_multi_prefix_wheel(self): for line in record_contents.splitlines(): self.assertFalse(line.startswith("/")) self.assertFileSha256Equal( - filename, "437127690584a035dc37542f64c38d1a6d6652655afc81f5a9472706343aae23" + filename, + { + # keep-sorted start + "python": "437127690584a035dc37542f64c38d1a6d6652655afc81f5a9472706343aae23", + "rust": "512f75085e9b0919daeaef32d0ebc5aa419bc23c65641a32ea38a72295e61a06", + # keep-sorted end + }, ) def test_custom_package_root_multi_prefix_reverse_order_wheel(self): @@ -353,7 +387,13 @@ def test_custom_package_root_multi_prefix_reverse_order_wheel(self): for line in record_contents.splitlines(): self.assertFalse(line.startswith("/")) self.assertFileSha256Equal( - filename, "265cc2ba4c99d0b62f1922f357de961f15f416bcee93ff307e4d4f04e4c067a3" + filename, + { + # keep-sorted start + "python": "265cc2ba4c99d0b62f1922f357de961f15f416bcee93ff307e4d4f04e4c067a3", + "rust": "510aa10aa0daa69e9903c946b046d6b998cc85209c715333ffc412e324880833", + # keep-sorted end + }, ) def test_python_requires_wheel(self): @@ -378,7 +418,13 @@ def test_python_requires_wheel(self): """, ) self.assertFileSha256Equal( - filename, "cb1d0bf64df1cbf23b7d4473a1c113cedbbea0d23209cdb4d2e5fe2edc68ceec" + filename, + { + # keep-sorted start + "python": "cb1d0bf64df1cbf23b7d4473a1c113cedbbea0d23209cdb4d2e5fe2edc68ceec", + "rust": "cc1060cccda6e422ec8bf92006e0c0a0ae7986d637814144de4dedb87fb448c6", + # keep-sorted end + }, ) def test_python_abi3_binary_wheel(self): @@ -443,7 +489,13 @@ def test_rule_creates_directory_and_is_included_in_wheel(self): ], ) self.assertFileSha256Equal( - filename, "2358a8ee58dd7ed1a89862e368a0eb00e83ec5de28995ecf0f3c38c2524102dc" + filename, + { + # keep-sorted start + "python": "2358a8ee58dd7ed1a89862e368a0eb00e83ec5de28995ecf0f3c38c2524102dc", + "rust": "1c0e3c6f2f529466c5f2fb93d1a1a21da47e4695571be738e794e5dde484e756", + # keep-sorted end + }, ) def test_rule_expands_workspace_status_keys_in_wheel_metadata(self): @@ -491,16 +543,27 @@ def test_requires_file_and_extra_requires_files(self): if line.startswith(b"Requires-Dist:"): requires.append(line.decode("utf-8").strip()) - self.assertEqual( - [ + # Rust wheelmaker parses requirements with pep508_rs, which + # algebraically simplifies PEP 508 environment markers. + want_requires = { + # keep-sorted start block=yes + "python": [ "Requires-Dist: tomli>=2.0.0", "Requires-Dist: starlark", "Requires-Dist: pyyaml!=6.0.1,>=6.0.0; extra == 'example'", 'Requires-Dist: toml; ((python_version == "3.11" or python_version == "3.12") and python_version != "3.8") and extra == \'example\'', 'Requires-Dist: wheel; (python_version == "3.11" or python_version == "3.12") and extra == \'example\'', ], - requires, - ) + "rust": [ + "Requires-Dist: tomli>=2.0.0", + "Requires-Dist: starlark", + "Requires-Dist: pyyaml!=6.0.1,>=6.0.0; extra == 'example'", + "Requires-Dist: toml; python_full_version >= '3.11' and python_full_version < '3.13' and extra == 'example'", + "Requires-Dist: wheel; python_full_version >= '3.11' and python_full_version < '3.13' and extra == 'example'", + ], + # keep-sorted end + } + self.assertEqual(want_requires[_WHEELMAKER_IMPL], requires) def test_empty_requires_file(self): filename = self._get_path("empty_requires_files-0.0.1-py3-none-any.whl") @@ -560,8 +623,11 @@ def test_extra_requires(self): requires.append(line.decode("utf-8").strip()) print(requires) - self.assertEqual( - [ + # Rust wheelmaker parses requirements with pep508_rs, which + # algebraically simplifies PEP 508 environment markers. + want_requires = { + # keep-sorted start block=yes + "python": [ "Requires-Dist: tomli>=2.0.0", "Requires-Dist: starlark", 'Requires-Dist: pytest; python_version != "3.8"', @@ -569,8 +635,17 @@ def test_extra_requires(self): 'Requires-Dist: toml; ((python_version == "3.11" or python_version == "3.12") and python_version != "3.8") and extra == \'example\'', 'Requires-Dist: wheel; (python_version == "3.11" or python_version == "3.12") and extra == \'example\'', ], - requires, - ) + "rust": [ + "Requires-Dist: tomli>=2.0.0", + "Requires-Dist: starlark", + "Requires-Dist: pytest; python_full_version != '3.8.*'", + "Requires-Dist: pyyaml!=6.0.1,>=6.0.0; extra == 'example'", + "Requires-Dist: toml; python_full_version >= '3.11' and python_full_version < '3.13' and extra == 'example'", + "Requires-Dist: wheel; python_full_version >= '3.11' and python_full_version < '3.13' and extra == 'example'", + ], + # keep-sorted end + } + self.assertEqual(want_requires[_WHEELMAKER_IMPL], requires) def test_requires_dist_depends_on_extras(self): filename = self._get_path( @@ -619,12 +694,15 @@ def test_requires_dist_depends_on_extras_file(self): requires.append(line.decode("utf-8").strip()) print(requires) - self.assertEqual( - [ - "Requires-Dist: extra_requires[example]==0.0.1", - ], - requires, - ) + # Rust wheelmaker parses requirements files with pep508_rs, which + # normalizes distribution names per PEP 503 (`_` -> `-`). + want_requires = { + # keep-sorted start + "python": ["Requires-Dist: extra_requires[example]==0.0.1"], + "rust": ["Requires-Dist: extra-requires[example]==0.0.1"], + # keep-sorted end + } + self.assertEqual(want_requires[_WHEELMAKER_IMPL], requires) def test_data_files_installed_in_folder(self): filename = self._get_path( diff --git a/python/private/BUILD.bazel b/python/private/BUILD.bazel index f3ebdfb8a5..45ae9831eb 100644 --- a/python/private/BUILD.bazel +++ b/python/private/BUILD.bazel @@ -741,6 +741,7 @@ bzl_library( ":toolchain_types", ":transition_labels", ":version", + "//python/private/toolchains:shrubbery_toolchain", ], ) diff --git a/python/private/py_wheel.bzl b/python/private/py_wheel.bzl index cfbbd597cb..3a6a297ecf 100644 --- a/python/private/py_wheel.bzl +++ b/python/private/py_wheel.bzl @@ -14,12 +14,20 @@ "Implementation of py_wheel rule" +load( + "//python/private/toolchains:shrubbery_toolchain.bzl", + "get_shrubbery_tool", +) load(":attributes.bzl", "CONFIG_SETTINGS_ATTR", "apply_config_settings_attr") load(":py_info.bzl", "PyInfo") load(":py_package.bzl", "py_package_lib") load(":rule_builders.bzl", "ruleb") load(":stamp_impl.bzl", "is_stamping_enabled") -load(":toolchain_types.bzl", "TARGET_TOOLCHAIN_TYPE") +load( + ":toolchain_types.bzl", + "SHRUBBERY_TOOLCHAIN_TYPE", + "TARGET_TOOLCHAIN_TYPE", +) load(":transition_labels.bzl", "TRANSITION_LABELS") load(":version.bzl", "version") @@ -611,12 +619,16 @@ def _py_wheel_impl(ctx): final_filename + ";" + file.path, ) + tool = get_shrubbery_tool(ctx, "wheelmaker", ctx.attr._wheelmaker) + prefix_args = ctx.actions.args() + prefix_args.add_all(tool.prefix_args) ctx.actions.run( mnemonic = "PyWheel", inputs = depset(direct = other_inputs, transitive = [inputs_to_package]), outputs = [outfile, name_file], - arguments = [args], - executable = ctx.executable._wheelmaker, + arguments = [prefix_args, args], + executable = tool.executable[DefaultInfo].files_to_run, + toolchain = tool.toolchain, # The default shell env is used to better support toolchains that look # up python at runtime using PATH. use_default_shell_env = True, @@ -691,5 +703,6 @@ in the way they expect. ), toolchains = [ ruleb.ToolchainType(TARGET_TOOLCHAIN_TYPE, mandatory = False), + ruleb.ToolchainType(SHRUBBERY_TOOLCHAIN_TYPE, mandatory = False), ], ).build() diff --git a/python/private/toolchains/BUILD.bazel b/python/private/toolchains/BUILD.bazel index a6dbabe0d3..e107026e3e 100644 --- a/python/private/toolchains/BUILD.bazel +++ b/python/private/toolchains/BUILD.bazel @@ -33,16 +33,17 @@ string_flag( visibility = NOT_ACTUALLY_PUBLIC, ) +# Leaf config_settings inherit package default_visibility (//:__subpackages__) +# because config_setting_group expands to alias(select(...)), whose resolved +# target visibility is checked at in-repo select() sites like //examples/wheel. config_setting( name = "is_need_shrubbery_auto", flag_values = {":need_shrubbery": "auto"}, - visibility = ["//visibility:private"], ) config_setting( name = "is_need_shrubbery_yes", flag_values = {":need_shrubbery": "yes"}, - visibility = ["//visibility:private"], ) selects.config_setting_group( diff --git a/tests/integration/prebuilt_toolchain/BUILD.bazel b/tests/integration/prebuilt_toolchain/BUILD.bazel index 18c2f0da1a..9ed1455168 100644 --- a/tests/integration/prebuilt_toolchain/BUILD.bazel +++ b/tests/integration/prebuilt_toolchain/BUILD.bazel @@ -1,3 +1,4 @@ +load("@rules_python//python:packaging.bzl", "py_wheel") load("@rules_python//python:py_binary.bzl", "py_binary") load("@rules_python//python/zipapp:py_zipapp_test.bzl", "py_zipapp_test") @@ -9,6 +10,13 @@ py_binary( }, ) +py_wheel( + name = "wheel", + distribution = "prebuilt_test", + version = "0.1.0", + deps = [":main"], +) + py_zipapp_test( name = "zipapp_test", binary = ":main", diff --git a/tests/integration/prebuilt_toolchain_test.py b/tests/integration/prebuilt_toolchain_test.py index b847bdb602..4eea05e402 100644 --- a/tests/integration/prebuilt_toolchain_test.py +++ b/tests/integration/prebuilt_toolchain_test.py @@ -73,6 +73,12 @@ def setUp(self): def test_prebuilt_shrubbery_toolchain(self): override_flag = f"--override_module=rules_python={self.rules_python_dir}" + self.run_bazel( + "build", + override_flag, + _NEED_SHRUBBERY_FLAG, + "//:wheel", + ) self.run_bazel( "test", override_flag, @@ -80,11 +86,12 @@ def test_prebuilt_shrubbery_toolchain(self): "//:zipapp_test", ) - for mnemonic in ( + for mnemonic, target in ( # keep-sorted start - "PyZipAppCreateExecutableZip", - "PyZipAppCreateMainPy", - "PyZipAppCreateZip", + ("PyWheel", "//:wheel"), + ("PyZipAppCreateExecutableZip", "//:zipapp_test"), + ("PyZipAppCreateMainPy", "//:zipapp_test"), + ("PyZipAppCreateZip", "//:zipapp_test"), # keep-sorted end ): with self.subTest(mnemonic=mnemonic): @@ -92,7 +99,7 @@ def test_prebuilt_shrubbery_toolchain(self): "aquery", override_flag, _NEED_SHRUBBERY_FLAG, - f"mnemonic({mnemonic}, //:zipapp_test)", + f"mnemonic({mnemonic}, {target})", ) self.assert_result_matches( aquery_res, diff --git a/tests/shrubbery/shrubbery_test.rs b/tests/shrubbery/shrubbery_test.rs index 97496e2ac9..41cf864965 100644 --- a/tests/shrubbery/shrubbery_test.rs +++ b/tests/shrubbery/shrubbery_test.rs @@ -17,7 +17,7 @@ fn temp_test_dir(prefix: &str) -> PathBuf { #[test] fn test_subcommands_registry_sorted_and_complete() { - assert_eq!(SUBCOMMANDS.len(), 3); + assert_eq!(SUBCOMMANDS.len(), 4); let mut sorted = SUBCOMMANDS.to_vec(); sorted.sort_unstable(); assert_eq!(SUBCOMMANDS, sorted.as_slice()); @@ -82,6 +82,28 @@ fn test_subcommand_forwarding() { ExitCode::SUCCESS ); assert!(out_main.exists()); + + let metadata = dir.join("metadata.txt"); + let out_whl = dir.join("pkg-1.0.0-py3-none-any.whl"); + fs::write(&metadata, "Metadata-Version: 2.1\nName: pkg\n") + .expect("metadata should be writable"); + + assert_eq!( + run_cli([ + "shrubbery", + "wheelmaker", + "--name", + "pkg", + "--version", + "1.0.0", + "--out", + out_whl.to_str().expect("out_whl path should be UTF-8"), + "--metadata_file", + metadata.to_str().expect("metadata path should be UTF-8"), + ]), + ExitCode::SUCCESS + ); + assert!(out_whl.exists()); } #[test] diff --git a/tests/shrubbery_toolchain/shrubbery_toolchain_tests.bzl b/tests/shrubbery_toolchain/shrubbery_toolchain_tests.bzl index da79d2df7a..a97bacf7d6 100644 --- a/tests/shrubbery_toolchain/shrubbery_toolchain_tests.bzl +++ b/tests/shrubbery_toolchain/shrubbery_toolchain_tests.bzl @@ -5,6 +5,7 @@ load("@rules_testing//lib:test_suite.bzl", "test_suite") load("@rules_testing//lib:truth.bzl", "matching") load("@rules_testing//lib:unit_test.bzl", "unit_test") load("@rules_testing//lib:util.bzl", rt_util = "util") +load("//python:packaging.bzl", "py_wheel") load("//python:py_binary.bzl", "py_binary") load("//python/private/toolchains:repo.bzl", "configure_tool_toolchains") # buildifier: disable=bzl-visibility load("//python/private/toolchains:shrubbery_toolchain.bzl", "shrubbery_toolchain") # buildifier: disable=bzl-visibility @@ -23,15 +24,22 @@ _tests = [] # skip there. # # On Windows, py_zipapp uses the Bazel launcher instead of a self-executable -# zip, so PyZipAppCreateExecutableZip is not created; skip there for zipapp -# self-executable tests. -_COMPATIBLE_WITH = SUPPORTS_BZLMOD + NOT_WINDOWS +# zip (so PyZipAppCreateExecutableZip is not created), so skip py_zipapp action +# tests on Windows. +_ZIPAPP_COMPATIBLE_WITH = SUPPORTS_BZLMOD + NOT_WINDOWS _SHRUBBERY_SUFFIX = "crates/shrubbery/shrubbery" _PYTHON_EXE_ZIP_MAKER_SUFFIX = "tools/zipapp/exe_zip_maker_.py" +_PYTHON_WHEELMAKER_SUFFIX = "tools/wheelmaker" _PYTHON_ZIP_MAIN_MAKER_SUFFIX = "tools/zipapp/zip_main_maker_.py" _PYTHON_ZIPPER_SUFFIX = "tools/zipapp/zipper_.py" _NEED_SHRUBBERY_FLAG = str(Label("//python/private/toolchains:need_shrubbery")) +def _endswith_exe(suffix): + return matching.custom( + "".format(suffix), + lambda v: v.removesuffix(".exe").endswith(suffix), + ) + def _define_py_zipapp_subject(name): rt_util.helper_target( py_binary, @@ -51,7 +59,7 @@ def _test_py_zipapp_default_uses_toolchain_shrubbery(name): name = name, impl = _test_py_zipapp_uses_toolchain_shrubbery_impl, target = name + "_subject", - attr_values = {"target_compatible_with": _COMPATIBLE_WITH}, + attr_values = {"target_compatible_with": _ZIPAPP_COMPATIBLE_WITH}, ) _tests.append(_test_py_zipapp_default_uses_toolchain_shrubbery) @@ -65,7 +73,7 @@ def _test_py_zipapp_uses_toolchain_shrubbery(name): config_settings = { _NEED_SHRUBBERY_FLAG: "yes", }, - attr_values = {"target_compatible_with": _COMPATIBLE_WITH}, + attr_values = {"target_compatible_with": _ZIPAPP_COMPATIBLE_WITH}, ) def _test_py_zipapp_uses_toolchain_shrubbery_impl(env, target): @@ -93,7 +101,7 @@ def _test_py_zipapp_flag_disabled_uses_python_fallbacks(name): config_settings = { _NEED_SHRUBBERY_FLAG: "no", }, - attr_values = {"target_compatible_with": _COMPATIBLE_WITH}, + attr_values = {"target_compatible_with": _ZIPAPP_COMPATIBLE_WITH}, ) def _test_py_zipapp_flag_disabled_uses_python_fallbacks_impl(env, target): @@ -111,6 +119,62 @@ def _test_py_zipapp_flag_disabled_uses_python_fallbacks_impl(env, target): _tests.append(_test_py_zipapp_flag_disabled_uses_python_fallbacks) +def _define_py_wheel_subject(name): + rt_util.helper_target( + py_wheel, + name = name + "_subject", + distribution = "mydist", + version = "1.0.0", + ) + +def _test_py_wheel_default_uses_toolchain_shrubbery(name): + _define_py_wheel_subject(name) + analysis_test( + name = name, + impl = _test_py_wheel_uses_toolchain_shrubbery_impl, + target = name + "_subject", + attr_values = {"target_compatible_with": SUPPORTS_BZLMOD}, + ) + +_tests.append(_test_py_wheel_default_uses_toolchain_shrubbery) + +def _test_py_wheel_uses_toolchain_shrubbery(name): + _define_py_wheel_subject(name) + analysis_test( + name = name, + impl = _test_py_wheel_uses_toolchain_shrubbery_impl, + target = name + "_subject", + config_settings = { + _NEED_SHRUBBERY_FLAG: "yes", + }, + attr_values = {"target_compatible_with": SUPPORTS_BZLMOD}, + ) + +def _test_py_wheel_uses_toolchain_shrubbery_impl(env, target): + action = env.expect.that_target(target).action_named("PyWheel") + action.argv().contains_predicate(_endswith_exe(_SHRUBBERY_SUFFIX)) + action.argv().contains("wheelmaker") + +_tests.append(_test_py_wheel_uses_toolchain_shrubbery) + +def _test_py_wheel_flag_disabled_uses_python_wheelmaker(name): + _define_py_wheel_subject(name) + analysis_test( + name = name, + impl = _test_py_wheel_flag_disabled_uses_python_wheelmaker_impl, + target = name + "_subject", + config_settings = { + _NEED_SHRUBBERY_FLAG: "no", + }, + attr_values = {"target_compatible_with": SUPPORTS_BZLMOD}, + ) + +def _test_py_wheel_flag_disabled_uses_python_wheelmaker_impl(env, target): + action = env.expect.that_target(target).action_named("PyWheel") + action.argv().contains_predicate(_endswith_exe(_PYTHON_WHEELMAKER_SUFFIX)) + +_tests.append(_test_py_wheel_flag_disabled_uses_python_wheelmaker) + def _test_prebuilt_file_toolchain_target(name): rt_util.helper_target( shrubbery_toolchain, diff --git a/tests/wheelmaker/BUILD.bazel b/tests/wheelmaker/BUILD.bazel new file mode 100644 index 0000000000..b58b22831a --- /dev/null +++ b/tests/wheelmaker/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_rust//rust:defs.bzl", "rust_test") + +package(default_visibility = ["//:__subpackages__"]) + +licenses(["notice"]) + +rust_test( + name = "wheelmaker_test", + size = "small", + srcs = ["wheelmaker_test.rs"], + edition = "2024", + deps = [ + "//crates/wheelmaker:wheelmaker_lib", + "@crates//:sha2", + "@crates//:zip", + ], +) diff --git a/tests/wheelmaker/wheelmaker_test.rs b/tests/wheelmaker/wheelmaker_test.rs new file mode 100644 index 0000000000..faf5048d6d --- /dev/null +++ b/tests/wheelmaker/wheelmaker_test.rs @@ -0,0 +1,1047 @@ +use std::collections::HashMap; +use std::env; +use std::fs::{self, File}; +use std::io::{Cursor, Read, Seek}; +use std::path::{Path, PathBuf}; +use std::process::ExitCode; +use std::sync::atomic::{AtomicUsize, Ordering}; + +use sha2::{Digest, Sha256}; +use wheelmaker_lib::{ + Cli, Options, REGULAR_FILE_UNIX_MODE, WhlFile, arcname_from, build_wheel, + escape_filename_distribution_name, expand_metadata_requires, get_new_requirement_line, + normalize_package_name, normalize_pep440, parse_args, resolve_stamp_with_lines, run_cli, + serialize_digest, +}; +use zip::{CompressionMethod, DateTime, System, ZipArchive}; + +static TEST_COUNTER: AtomicUsize = AtomicUsize::new(0); + +fn unwrap_run_options(cli: Cli) -> Options { + match cli { + Cli::Run(opts) => *opts, + Cli::Help => panic!("expected Cli::Run, got Cli::Help"), + } +} + +fn read_zip_entries_from_reader(reader: R) -> Vec { + let mut archive = ZipArchive::new(reader).expect("output zip should be a valid archive"); + let mut entries = Vec::with_capacity(archive.len()); + for idx in 0..archive.len() { + let mut entry = archive.by_index(idx).expect("zip entry should be readable"); + let name = entry + .name() + .expect("zip entry name should be valid UTF-8") + .into_owned(); + let system = entry.system(); + let compression = entry.compression(); + let last_modified = entry.last_modified(); + let unix_mode = entry.unix_mode(); + let file_size = entry.size(); + let mut data = Vec::with_capacity(file_size as usize); + entry + .read_to_end(&mut data) + .expect("zip entry payload should decompress cleanly"); + assert_eq!( + data.len() as u64, + file_size, + "uncompressed size mismatch for {name}" + ); + + entries.push(ParsedZipEntry { + name, + system, + compression, + last_modified, + unix_mode, + file_size, + data, + }); + } + + entries +} + +fn read_zip_entries(zip_path: &Path) -> Vec { + let file = File::open(zip_path).expect("zip file should be readable"); + read_zip_entries_from_reader(file) +} + +fn assert_reproducible_metadata(entries: &[ParsedZipEntry], expected_method: CompressionMethod) { + for entry in entries { + assert_eq!(entry.system, System::Unix, "{}", entry.name); + assert_eq!( + entry.last_modified, + Some(DateTime::DEFAULT), + "{}", + entry.name + ); + assert_eq!( + entry.unix_mode, + Some(REGULAR_FILE_UNIX_MODE), + "{}", + entry.name + ); + assert_eq!(entry.compression, expected_method, "{}", entry.name); + assert_eq!(entry.file_size, entry.data.len() as u64, "{}", entry.name); + } +} + +#[test] +fn test_record_csv_quoting() { + let mut sha_a = Sha256::new(); + sha_a.update(b"a"); + let digest_a = serialize_digest(&sha_a.finalize()); + + let mut whl = WhlFile::new(Cursor::new(Vec::new()), "test-1.0.0", Vec::new(), "", true); + whl.add_string("foo/bar.py", b"a") + .expect("simple path should be writable"); + whl.add_string("foo,bar/baz.py", b"a") + .expect("comma path should be writable"); + whl.add_string("/leading/slash.py", b"a") + .expect("leading-slash path should be writable"); + whl.add_string(r"\leading\backslash.py", b"a") + .expect("leading-backslash path should be writable"); + whl.add_string("has\"quote.py", b"a") + .expect("quote path should be writable"); + let record = whl + .add_recordfile() + .expect("RECORD entry should be writable"); + let cursor = whl.finish().expect("in-memory wheel should finalize"); + let entries = read_zip_entries_from_reader(Cursor::new(cursor.into_inner())); + assert_reproducible_metadata(&entries, CompressionMethod::Deflated); + let names: Vec<&str> = entries.iter().map(|e| e.name.as_str()).collect(); + assert_eq!( + names, + vec![ + "foo/bar.py", + "foo,bar/baz.py", + "leading/slash.py", + r"leading\backslash.py", + "has\"quote.py", + "test-1.0.0.dist-info/RECORD", + ] + ); + + assert_eq!( + record, + format!( + concat!( + "foo/bar.py,{digest_a},1\n", + "\"foo,bar/baz.py\",{digest_a},1\n", + "leading/slash.py,{digest_a},1\n", + "leading\\backslash.py,{digest_a},1\n", + "\"has\"\"quote.py\",{digest_a},1\n", + "test-1.0.0.dist-info/RECORD,,\n", + ), + digest_a = digest_a, + ) + ); +} + +#[test] +fn test_arcname_from() { + struct Case<'a> { + name: &'a str, + distribution_prefix: &'a str, + strip_path_prefixes: &'a [&'a str], + add_path_prefix: &'a str, + expected: &'a str, + } + + let cases = [ + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &[], + add_path_prefix: "", + expected: "a/b/c/file.py", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &["a"], + add_path_prefix: "", + expected: "/b/c/file.py", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &["a/b/"], + add_path_prefix: "", + expected: "c/file.py", + }, + Case { + name: r"a\b\c\file.py", + distribution_prefix: "", + strip_path_prefixes: &["a/b/"], + add_path_prefix: "", + expected: "c/file.py", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &["a/", "b/"], + add_path_prefix: "", + expected: "b/c/file.py", + }, + Case { + name: "foo/bar/baz/file.py", + distribution_prefix: "", + strip_path_prefixes: &["foo", "foo/bar/baz"], + add_path_prefix: "", + expected: "/bar/baz/file.py", + }, + Case { + name: "foo/bar/baz/file.py", + distribution_prefix: "", + strip_path_prefixes: &["foo/bar/baz", "foo"], + add_path_prefix: "", + expected: "/file.py", + }, + Case { + name: "foo/file2.py", + distribution_prefix: "", + strip_path_prefixes: &["foo/bar/baz", "foo"], + add_path_prefix: "", + expected: "/file2.py", + }, + Case { + name: "mylib-0.0.1-dist-info/WHEEL", + distribution_prefix: "mylib", + strip_path_prefixes: &[], + add_path_prefix: "", + expected: "mylib-0.0.1-dist-info/WHEEL", + }, + Case { + name: "mylib/a/b/c/WHEEL", + distribution_prefix: "mylib", + strip_path_prefixes: &["mylib"], + add_path_prefix: "", + expected: "mylib/a/b/c/WHEEL", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &[], + add_path_prefix: "namespace/", + expected: "namespace/a/b/c/file.py", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &["a"], + add_path_prefix: "namespace", + expected: "namespace/b/c/file.py", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &["a/b/"], + add_path_prefix: "namespace_", + expected: "namespace_c/file.py", + }, + Case { + name: "a/b/c/file.py", + distribution_prefix: "", + strip_path_prefixes: &["a/b/"], + add_path_prefix: r"namespace\sub\", + expected: "namespace/sub/c/file.py", + }, + ]; + + for c in cases { + let prefixes: Vec = c + .strip_path_prefixes + .iter() + .map(|s| (*s).to_string()) + .collect(); + let got = arcname_from(c.name, c.distribution_prefix, &prefixes, c.add_path_prefix); + assert_eq!(got, c.expected, "case: {}", c.name); + } +} + +#[test] +fn test_get_new_requirement_line() { + assert_eq!( + get_new_requirement_line("requests>=2.0", "").expect("requirement should parse"), + "Requires-Dist: requests>=2.0" + ); + assert_eq!( + get_new_requirement_line("requests>=2.0", "extra=='dev'") + .expect("requirement with extra should parse"), + "Requires-Dist: requests>=2.0; extra == 'dev'" + ); + assert_eq!( + get_new_requirement_line( + "requests @ git+https://github.com/psf/requests.git@3aa6386c3", + "" + ) + .expect("URL requirement should parse"), + "Requires-Dist: requests @ git+https://github.com/psf/requests.git@3aa6386c3" + ); + assert_eq!( + get_new_requirement_line( + "requests @ https://example.com/requests-2.0.whl", + "extra == 'dev'" + ) + .expect("URL requirement with extra should parse"), + "Requires-Dist: requests @ https://example.com/requests-2.0.whl ; extra == 'dev'" + ); + assert_eq!( + get_new_requirement_line("requests>=2.0; python_version>='3.6'", "") + .expect("marker requirement should parse"), + "Requires-Dist: requests>=2.0; python_full_version >= '3.6'" + ); + assert_eq!( + get_new_requirement_line("requests>=2.0; python_version>='3.6'", "extra=='dev'") + .expect("marker + extra requirement should parse"), + "Requires-Dist: requests>=2.0; python_full_version >= '3.6' and extra == 'dev'" + ); + assert_eq!( + get_new_requirement_line("pyyaml>=6.0.0,!=6.0.1", "extra == 'example'") + .expect("multi-specifier requirement should parse"), + "Requires-Dist: pyyaml!=6.0.1,>=6.0.0; extra == 'example'" + ); + assert_eq!( + get_new_requirement_line( + concat!( + "toml; (python_version == \"3.11\" or python_version == \"3.12\") ", + "and python_version != \"3.8\"", + ), + "extra == 'example'" + ) + .expect("compound marker requirement should parse"), + concat!( + "Requires-Dist: toml; python_full_version >= '3.11' and ", + "python_full_version < '3.13' and extra == 'example'", + ) + ); + assert_eq!( + get_new_requirement_line( + "wheel; python_version == \"3.11\" or python_version == \"3.12\" ", + "extra == 'example'" + ) + .expect("trailing-space marker requirement should parse"), + concat!( + "Requires-Dist: wheel; python_full_version >= '3.11' and ", + "python_full_version < '3.13' and extra == 'example'", + ) + ); + assert_eq!( + get_new_requirement_line("extra_requires[example]==0.0.1", "") + .expect("extra dependency requirement should parse"), + "Requires-Dist: extra-requires[example]==0.0.1" + ); + assert_eq!( + get_new_requirement_line( + "baz~=1.2.3; extra == 'test_extra' or 'dev.extra' == extra", + "" + ) + .expect("extra marker normalization should succeed"), + "Requires-Dist: baz~=1.2.3; extra == 'dev-extra' or extra == 'test-extra'" + ); + assert_eq!( + get_new_requirement_line( + "baz~=1.2.3; extra == 'test_extra' or 'dev.extra' == extra", + "extra == 'dev.extra'" + ) + .expect("extra marker conjunction should simplify"), + "Requires-Dist: baz~=1.2.3; extra == 'dev-extra'" + ); + + let bad_req = format!( + "{:#}", + get_new_requirement_line("not a valid === req ???", "").unwrap_err() + ); + assert!( + bad_req.contains("parsing requirement"), + "unexpected error: {bad_req}" + ); + let bad_marker = format!( + "{:#}", + get_new_requirement_line("requests>=2.0", "not_a_marker == 'x'").unwrap_err() + ); + assert!( + bad_marker.contains("parsing extra marker"), + "unexpected error: {bad_marker}" + ); +} + +#[test] +fn test_escaping_and_pep440_normalization() { + assert_eq!( + normalize_package_name("File--Name_Escaping.Pkg") + .expect("package name normalization should succeed"), + "file-name-escaping-pkg" + ); + assert_eq!( + escape_filename_distribution_name("File--Name-Escaping") + .expect("distribution escaping should succeed"), + "file_name_escaping" + ); + + assert_eq!( + normalize_pep440("v0.0.1.RC1+ubuntu-r7").expect("PEP 440 version should normalize"), + "0.0.1rc1+ubuntu.r7" + ); + assert_eq!( + normalize_pep440("01.02.003").expect("zero-padded PEP 440 version should normalize"), + "1.2.3" + ); + assert_eq!( + normalize_pep440("1.2.3.dev0").expect("dev version should normalize"), + "1.2.3.dev0" + ); + assert_eq!( + normalize_pep440("1.0-2").expect("implicit post version should normalize"), + "1.0.post2" + ); + assert_eq!( + normalize_pep440("1!2.0.rev3").expect("epoch + rev version should normalize"), + "1!2.0.post3" + ); + assert_eq!( + normalize_pep440("0.1.{BUILD_TIMESTAMP}") + .expect("unstamped placeholder version should normalize"), + "0.1.0+0.1.build.timestamp" + ); + assert_eq!( + normalize_pep440("{BUILD_EMBED_LABEL}").expect("bare placeholder version should normalize"), + "0+build.embed.label" + ); + assert_eq!( + normalize_pep440("1.0+local.{STAMP}") + .expect("local + placeholder version should normalize"), + "1.0+local.0.1.0.local.stamp" + ); + assert_eq!( + normalize_pep440("invalid_ver").expect("fallback local version should normalize"), + "0+invalid.ver" + ); + + assert!(normalize_pep440("").is_err()); + assert!(normalize_pep440("---").is_err()); +} + +#[test] +fn test_expand_metadata_requires_shared_file_with_and_without_extra() { + let tmp = TempDir::new("shared_reqs"); + let reqs_file = tmp.path().join("shared.txt"); + fs::write(&reqs_file, "tomli>=2.0.0\nstarlark # inline comment\n") + .expect("shared.txt should be writable"); + + // Regression check: when the same @file path appears both bare and with `; extra == '...'`, + // expanding the bare directive must not corrupt the extra directive's line. + let raw = format!( + concat!( + "Metadata-Version: 2.1\n", + "Name: shared\n", + "Requires-Dist: @{reqs}\n", + "Provides-Extra: dev\n", + "Requires-Dist: @{reqs}; extra == 'dev'\n", + ), + reqs = reqs_file.display(), + ); + let expanded = expand_metadata_requires(&raw).expect("metadata expansion should succeed"); + assert_eq!( + expanded, + concat!( + "Metadata-Version: 2.1\n", + "Name: shared\n", + "Requires-Dist: tomli>=2.0.0\n", + "Requires-Dist: starlark\n", + "Provides-Extra: dev\n", + "Requires-Dist: tomli>=2.0.0; extra == 'dev'\n", + "Requires-Dist: starlark; extra == 'dev'\n", + ) + ); +} + +#[test] +fn test_end_to_end_customized_wheel_and_record() { + let tmp = TempDir::new("customized"); + let data_commas = tmp.path().join("data,with,commas.txt"); + fs::write(&data_commas, b"hello world\n").expect("comma data file should be writable"); + + let empty_pyi = tmp.path().join("mod.pyi"); + fs::write(&empty_pyi, b"").expect("empty pyi file should be writable"); + + let sub_dir = tmp.path().join("someDir"); + fs::create_dir_all(&sub_dir).expect("sub_dir should be creatable"); + fs::write(sub_dir.join("foo.py"), b"x = 1\n").expect("foo.py should be writable"); + + let input_list_path = tmp.path().join("inputs.txt"); + fs::write( + &input_list_path, + format!( + concat!( + "examples/wheel/lib/data,with,commas.txt;{}\n", + "examples/wheel/lib/mod.pyi;{}\n", + "examples/wheel/someDir;{}\n", + ), + data_commas.display(), + empty_pyi.display(), + sub_dir.display(), + ), + ) + .expect("input_file_list should be writable"); + + let reqs_file = tmp.path().join("requires.txt"); + fs::write( + &reqs_file, + "# comment\n--index-url https://pypi.org\n\ntomli>=2.0.0\nstarlark # inline comment\n", + ) + .expect("requires.txt should be writable"); + + let extra_reqs_file = tmp.path().join("extra_requires.txt"); + fs::write( + &extra_reqs_file, + concat!( + "pyyaml>=6.0.0,!=6.0.1\n", + "toml; (python_version == \"3.11\" or python_version == \"3.12\") ", + "and python_version != \"3.8\"\n", + ), + ) + .expect("extra_requires.txt should be writable"); + + let metadata_file = tmp.path().join("metadata.txt"); + fs::write( + &metadata_file, + format!( + concat!( + "Metadata-Version: 2.1\n", + "Name: File--Name-Escaping\n", + "Author: Example Author: żółw\n", + "Requires-Dist: @{}\n", + "Provides-Extra: example\n", + "Requires-Dist: @{}; extra == 'example'\n", + ), + reqs_file.display(), + extra_reqs_file.display(), + ), + ) + .expect("metadata.txt should be writable"); + + let desc_file = tmp.path().join("README.md"); + fs::write(&desc_file, b"This is a sample description of a wheel.") + .expect("README.md should be writable"); + + let ep_file = tmp.path().join("entry_points.txt"); + fs::write(&ep_file, b"[console_scripts]\nmain = foo.bar:baz") + .expect("entry_points.txt should be writable"); + + let notice_file = tmp.path().join("NOTICE"); + fs::write(¬ice_file, b"Notice text\n").expect("NOTICE should be writable"); + + let out_whl = tmp.path().join("nested").join("out.whl"); + let name_file = tmp.path().join("nested_name").join("out.name"); + + let opts = unwrap_run_options( + parse_args([ + "--name", + "File--Name-Escaping", + "--version", + "v0.0.1.RC1+ubuntu-r7", + "--python_tag", + "py3", + "--abi", + "none", + "--platform", + "any", + "--out", + out_whl.to_str().expect("out_whl path should be UTF-8"), + "--name_file", + name_file.to_str().expect("name_file path should be UTF-8"), + "--strip_path_prefix=examples/wheel/", + "--path_prefix=pkg/", + "--input_file_list", + input_list_path + .to_str() + .expect("input_list_path should be UTF-8"), + "--metadata_file", + metadata_file + .to_str() + .expect("metadata_file path should be UTF-8"), + "--description_file", + desc_file.to_str().expect("desc_file path should be UTF-8"), + "--entry_points_file", + ep_file.to_str().expect("ep_file path should be UTF-8"), + "--extra_distinfo_file", + &format!("NOTICE;{}", notice_file.display()), + "--data_files", + &format!("scripts/NOTICE;{}", notice_file.display()), + ]) + .expect("customized wheel args should parse"), + ); + + build_wheel(&opts).expect("build_wheel should succeed"); + + assert_eq!( + fs::read_to_string(&name_file).expect("name_file should be readable"), + "file_name_escaping-0.0.1rc1+ubuntu.r7-py3-none-any.whl" + ); + + let entries = read_zip_entries(&out_whl); + assert_reproducible_metadata(&entries, CompressionMethod::Deflated); + + let names: Vec<&str> = entries.iter().map(|e| e.name.as_str()).collect(); + assert_eq!( + names, + vec![ + "pkg/lib/data,with,commas.txt", + "pkg/lib/mod.pyi", + "pkg/someDir/foo.py", + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/WHEEL", + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/METADATA", + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/entry_points.txt", + "file_name_escaping-0.0.1rc1+ubuntu.r7.data/scripts/NOTICE", + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/NOTICE", + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/RECORD", + ] + ); + + let by_name: HashMap = + entries.into_iter().map(|e| (e.name.clone(), e)).collect(); + + assert_eq!( + by_name["file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/WHEEL"].text(), + concat!( + "Wheel-Version: 1.0\n", + "Generator: bazel-wheelmaker 1.0\n", + "Root-Is-Purelib: true\n", + "Tag: py3-none-any\n", + ) + ); + + assert_eq!( + by_name["file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/METADATA"].text(), + concat!( + "Metadata-Version: 2.1\n", + "Name: File--Name-Escaping\n", + "Author: Example Author: żółw\n", + "Requires-Dist: tomli>=2.0.0\n", + "Requires-Dist: starlark\n", + "Provides-Extra: example\n", + "Requires-Dist: pyyaml!=6.0.1,>=6.0.0; extra == 'example'\n", + "Requires-Dist: toml; python_full_version >= '3.11' and ", + "python_full_version < '3.13' and extra == 'example'\n", + "Version: 0.0.1rc1+ubuntu.r7\n\n", + "This is a sample description of a wheel.\n", + ) + ); + + let record_text = by_name["file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/RECORD"].text(); + let record_lines: Vec<&str> = record_text.lines().collect(); + assert_eq!(record_lines.len(), 9); + let mut sha = Sha256::new(); + sha.update(b"hello world\n"); + let expected_first = format!( + "\"pkg/lib/data,with,commas.txt\",{},12", + serialize_digest(&sha.finalize()) + ); + assert_eq!(record_lines[0], expected_first); + assert_eq!( + record_lines[8], + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/RECORD,," + ); +} + +#[test] +fn test_stamping_semantics_and_empty_requires_and_no_compress() { + let tmp = TempDir::new("stamping"); + let volatile_file = tmp.path().join("volatile-status.txt"); + fs::write( + &volatile_file, + "BUILD_TIMESTAMP 123456\nKEY_WITHOUT_SPACE\n", + ) + .expect("volatile status file should be writable"); + + let stable_file = tmp.path().join("stable-status.txt"); + fs::write(&stable_file, "BUILD_USER alice\n").expect("stable status file should be writable"); + + assert_eq!( + resolve_stamp_with_lines( + "pkg_{BUILD_USER}_{BUILD_TIMESTAMP}_{KEY_WITHOUT_SPACE}", + &[ + "BUILD_TIMESTAMP 123456".to_string(), + "KEY_WITHOUT_SPACE".to_string(), + "BUILD_USER alice".to_string(), + ] + ), + "pkg_alice_123456_" + ); + + let empty_reqs = tmp.path().join("empty_requires.txt"); + fs::write(&empty_reqs, "\n# only comments\n").expect("empty_requires.txt should be writable"); + + // Summary and description intentionally contain `{BUILD_USER}` to verify stamping only + // resolves `name` and `version` (matching `tools/wheelmaker.py`) and never mutates metadata + // headers or description prose. + let metadata_file = tmp.path().join("metadata.txt"); + fs::write( + &metadata_file, + format!( + concat!( + "Metadata-Version: 2.1\n", + "Name: my_pkg{{BUILD_USER}}\n", + "Summary: Literal {{BUILD_USER}} placeholder\n", + "Requires-Dist: @{}\n", + ), + empty_reqs.display() + ), + ) + .expect("metadata.txt should be writable"); + + let desc_file = tmp.path().join("desc.txt"); + fs::write(&desc_file, "Body mentions {BUILD_TIMESTAMP} literally.") + .expect("desc.txt should be writable"); + + let out_whl = tmp.path().join("stamped.whl"); + let name_file = tmp.path().join("stamped.name"); + let flagfile = tmp.path().join("flags.params"); + fs::write( + &flagfile, + format!( + concat!( + "--name\nmy_pkg{{BUILD_USER}}\n", + "--version\n0.1.{{BUILD_TIMESTAMP}}\n", + "--platform\nmanylinux2014_x86_64\n", + "--abi\nabi3\n", + "--python_tag\ncp38\n", + "--no_compress\n", + "--out\n{}\n", + "--name_file\n{}\n", + "--metadata_file\n{}\n", + "--description_file\n{}\n", + "--volatile_status_file\n{}\n", + "--stable_status_file\n{}\n", + ), + out_whl.display(), + name_file.display(), + metadata_file.display(), + desc_file.display(), + volatile_file.display(), + stable_file.display(), + ), + ) + .expect("flagfile should be writable"); + + assert_eq!( + run_cli([format!("@{}", flagfile.display())]), + ExitCode::SUCCESS + ); + + assert_eq!( + fs::read_to_string(&name_file).expect("stamped.name should be readable"), + "my_pkgalice-0.1.123456-cp38-abi3-manylinux2014_x86_64.whl" + ); + + let entries = read_zip_entries(&out_whl); + assert_reproducible_metadata(&entries, CompressionMethod::Stored); + + let by_name: HashMap = + entries.into_iter().map(|e| (e.name.clone(), e)).collect(); + + assert_eq!( + by_name["my_pkgalice-0.1.123456.dist-info/WHEEL"].text(), + concat!( + "Wheel-Version: 1.0\n", + "Generator: bazel-wheelmaker 1.0\n", + "Root-Is-Purelib: false\n", + "Tag: cp38-abi3-manylinux2014_x86_64\n", + ) + ); + + assert_eq!( + by_name["my_pkgalice-0.1.123456.dist-info/METADATA"].text(), + concat!( + "Metadata-Version: 2.1\n", + "Name: my_pkgalice\n", + "Summary: Literal {BUILD_USER} placeholder\n", + "Version: 0.1.123456\n\n", + "Body mentions {BUILD_TIMESTAMP} literally.\n", + ) + ); + + // Passing only one status file must leave placeholders unresolved, matching Python + // `if arguments.volatile_status_file and arguments.stable_status_file:`. + let half_whl = tmp.path().join("half_stamped.whl"); + let half_name = tmp.path().join("half_stamped.name"); + assert_eq!( + run_cli([ + "--name", + "my_pkg{BUILD_USER}", + "--version", + "0.1.{BUILD_TIMESTAMP}", + "--out", + half_whl.to_str().expect("half_whl path should be UTF-8"), + "--name_file", + half_name.to_str().expect("half_name path should be UTF-8"), + "--metadata_file", + metadata_file + .to_str() + .expect("metadata_file path should be UTF-8"), + "--volatile_status_file", + volatile_file + .to_str() + .expect("volatile_file path should be UTF-8"), + ]), + ExitCode::SUCCESS + ); + assert_eq!( + fs::read_to_string(&half_name).expect("half_stamped.name should be readable"), + "my_pkg{build_user}-0.1.0+0.1.build.timestamp-py3-none-any.whl" + ); +} + +#[test] +fn test_build_tag_inline_requires_and_duplicate_inputs() { + let tmp = TempDir::new("build_tag"); + let extra_reqs = tmp.path().join("extra_reqs.txt"); + fs::write(&extra_reqs, "pytest>=7.0\n").expect("extra_reqs.txt should be writable"); + + let f_first = tmp.path().join("first.py"); + let f_second = tmp.path().join("second.py"); + fs::write(&f_first, b"v = 1\n").expect("first.py should be writable"); + fs::write(&f_second, b"v = 2\n").expect("second.py should be writable"); + + let empty_desc = tmp.path().join("empty_desc.md"); + fs::write(&empty_desc, b"").expect("empty_desc.md should be writable"); + + let metadata_file = tmp.path().join("metadata.txt"); + fs::write( + &metadata_file, + format!( + concat!( + "Metadata-Version: 2.1\n", + "Name: Demo-Pkg\n", + "Requires-Dist: extra_requires[example]==0.0.1\n", + "Requires-Dist: six>=1.16.0,!=1.16.1; python_version>='3.8'; extra == 'dev'\n", + "Provides-Extra: dev\n", + "Requires-Dist: @{}; extra == 'dev'\n", + ), + extra_reqs.display() + ), + ) + .expect("metadata.txt should be writable"); + + let out_whl = tmp.path().join("demo.whl"); + let name_file = tmp.path().join("demo.name"); + + let opts = unwrap_run_options( + parse_args([ + "--name", + "Demo-Pkg", + "--version", + "1.0.0", + "--build_tag", + "1build", + "--python_tag", + "py2.py3", + "--abi", + "none", + "--platform", + "any", + "--out", + out_whl.to_str().expect("out_whl path should be UTF-8"), + "--name_file", + name_file.to_str().expect("name_file path should be UTF-8"), + "--metadata_file", + metadata_file + .to_str() + .expect("metadata_file path should be UTF-8"), + "--description_file", + empty_desc + .to_str() + .expect("empty_desc path should be UTF-8"), + "--input_file", + &format!("demo/mod.py;{}", f_first.display()), + "--input_file", + &format!("demo/mod.py;{}", f_second.display()), + ]) + .expect("build_tag wheel args should parse"), + ); + + build_wheel(&opts).expect("build_wheel should succeed"); + + assert_eq!( + fs::read_to_string(&name_file).expect("demo.name should be readable"), + "demo_pkg-1.0.0-1build-py2.py3-none-any.whl" + ); + + let entries = read_zip_entries(&out_whl); + assert_reproducible_metadata(&entries, CompressionMethod::Deflated); + let by_name: HashMap = + entries.into_iter().map(|e| (e.name.clone(), e)).collect(); + + assert_eq!(by_name["demo/mod.py"].text(), "v = 2\n"); + assert_eq!( + by_name["demo_pkg-1.0.0.dist-info/WHEEL"].text(), + concat!( + "Wheel-Version: 1.0\n", + "Generator: bazel-wheelmaker 1.0\n", + "Root-Is-Purelib: true\n", + "Tag: py2.py3-none-any\n", + ) + ); + + assert_eq!( + by_name["demo_pkg-1.0.0.dist-info/METADATA"].text(), + concat!( + "Metadata-Version: 2.1\n", + "Name: Demo-Pkg\n", + "Requires-Dist: extra_requires[example]==0.0.1\n", + "Requires-Dist: six!=1.16.1,>=1.16.0; ", + "python_full_version >= '3.8' and extra == 'dev'\n", + "Provides-Extra: dev\n", + "Requires-Dist: pytest>=7.0; extra == 'dev'\n", + "Version: 1.0.0\n\n", + "UNKNOWN\n", + ) + ); +} + +#[test] +fn test_help_and_errors() { + assert_eq!( + parse_args(["--help"]).expect("--help should parse"), + Cli::Help + ); + assert_eq!(parse_args(["-h"]).expect("-h should parse"), Cli::Help); + assert_eq!(run_cli(["--help"]), ExitCode::SUCCESS); + + // Missing required flags (--name, --version, --metadata_file) fail in parse_args before any + // filesystem writes. + assert!(parse_args::<_, &str>([]).is_err()); + assert!(parse_args(["--name=pkg", "--version=1.0.0"]).is_err()); + assert!(parse_args(["--name=pkg", "--metadata_file=m.txt"]).is_err()); + assert!(parse_args(["--version=1.0.0", "--metadata_file=m.txt"]).is_err()); + + // Bare "@" flagfile fails cleanly via argfile. + assert!(parse_args(["@"]).is_err()); + + // Unknown flags (including removed --description_content_type) and unexpected positional + // arguments (including empty string) are rejected. + assert!( + parse_args([ + "--name=pkg", + "--version=1.0.0", + "--metadata_file=m.txt", + "--compress", + ]) + .is_err() + ); + assert!( + parse_args([ + "--name=pkg", + "--version=1.0.0", + "--metadata_file=m.txt", + "--description_content_type=text/markdown", + ]) + .is_err() + ); + assert!( + parse_args([ + "--name=pkg", + "--version=1.0.0", + "--metadata_file=m.txt", + "--extra_requires_file=r.txt;dev", + ]) + .is_err() + ); + assert!(parse_args(["--name=pkg", "--version=1.0.0", "--metadata_file=m.txt", "",]).is_err()); + + // Malformed inline Requires-Dist with empty package before `;` fails instead of passing + // through silently. + assert!(expand_metadata_requires("Requires-Dist: ; extra == 'dev'\n").is_err()); + + // Malformed `target;real_path` flag value. + assert!( + parse_args([ + "--name=pkg", + "--version=1.0.0", + "--metadata_file=m.txt", + "--input_file=missing_semicolon", + ]) + .is_err() + ); + + // Malformed `input_file_list` line names the list path and line. + let tmp = TempDir::new("errors"); + let bad_list = tmp.path().join("bad_inputs.txt"); + fs::write(&bad_list, "no_semicolon_here\n").expect("bad_inputs.txt should be writable"); + let metadata = tmp.path().join("metadata.txt"); + fs::write(&metadata, "Metadata-Version: 2.1\nName: pkg\n") + .expect("metadata.txt should be writable"); + let out_whl = tmp.path().join("err.whl"); + + let opts = unwrap_run_options( + parse_args([ + "--name=pkg", + "--version=1.0.0", + &format!("--metadata_file={}", metadata.display()), + &format!("--input_file_list={}", bad_list.display()), + &format!("--out={}", out_whl.display()), + ]) + .expect("args should parse"), + ); + let err = format!("{:#}", build_wheel(&opts).unwrap_err()); + assert!( + err.contains("no_semicolon_here") && err.contains("bad_inputs.txt"), + "unexpected error: {err}" + ); + assert!(!out_whl.exists()); + + assert_eq!(run_cli::<_, &str>([]), ExitCode::FAILURE); +} + +#[derive(Debug, Clone)] +struct ParsedZipEntry { + /// Archive entry path relative to the zip root. + name: String, + system: System, + compression: CompressionMethod, + last_modified: Option, + unix_mode: Option, + file_size: u64, + data: Vec, +} + +impl ParsedZipEntry { + fn text(&self) -> String { + String::from_utf8(self.data.clone()).expect("entry bytes should be valid UTF-8") + } +} + +struct TempDir { + path: PathBuf, +} + +impl TempDir { + fn new(prefix: &str) -> Self { + let id = TEST_COUNTER.fetch_add(1, Ordering::SeqCst); + let base = env::var_os("TEST_TMPDIR") + .map(PathBuf::from) + .unwrap_or_else(env::temp_dir); + let path = base.join(format!( + "wheelmaker_test_{}_{}_{}", + prefix, + std::process::id(), + id + )); + let _ = fs::remove_dir_all(&path); + fs::create_dir_all(&path).expect("temp dir should be creatable"); + Self { path } + } + + fn path(&self) -> &Path { + &self.path + } +} + +impl Drop for TempDir { + fn drop(&mut self) { + let _ = fs::remove_dir_all(&self.path); + } +} From a4e2ce4ede8e7f37ea9bb85670a33f081a83b9de Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 11:25:25 -0800 Subject: [PATCH 2/7] refactor(wheel): clarify BLOCK_SIZE choice and port missing inline comments Explain why wheelmaker uses a 256 KiB buffer (and make BLOCK_SIZE private since nothing outside wheelmaker_lib imports it), and copy over the remaining inline comments from tools/wheelmaker.py covering deterministic entry sorting, streaming hash/size calculation, and minimal CSV quoting in RECORD. --- crates/wheelmaker/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/wheelmaker/src/lib.rs b/crates/wheelmaker/src/lib.rs index 414f2e05ae..d9d50b7840 100644 --- a/crates/wheelmaker/src/lib.rs +++ b/crates/wheelmaker/src/lib.rs @@ -28,7 +28,12 @@ use zip::write::SimpleFileOptions; use zip::{CompressionMethod, DateTime, System, ZIP64_BYTES_THR, ZipWriter}; /// Read/write buffer size when streaming files into the `.whl` archive and SHA-256 hasher. -pub const BLOCK_SIZE: usize = 256 * 1024; +/// +/// 256 KiB matches the other `shrubbery` tools (`zipper`, `exe_zip_maker`, `zip_main_maker`). It +/// is large enough to coalesce small wheel entries into few `write` syscalls and amortize `read` +/// syscalls on large files, while staying small enough to fit in L2 cache where bigger buffers +/// stop paying off. +const BLOCK_SIZE: usize = 256 * 1024; /// Fixed timestamp for all entries so output is deterministic. This is the earliest MS-DOS /// timestamp a zip can represent (1980-01-01 00:00:00) and matches `_ZIP_EPOCH` in @@ -384,6 +389,7 @@ fn collect_sorted_inputs(options: &Options) -> Result> { } let mut sorted_files: Vec<(String, PathBuf)> = get_files_to_package(&input_files).into_iter().collect(); + // Sort the files for reproducible order in the archive. sorted_files.sort_unstable_by(|a, b| a.0.cmp(&b.0)); Ok(sorted_files) } @@ -715,6 +721,7 @@ impl WhlFile { }; entries.push((file_name, entry.path())); } + // Sort directory entries for reproducible order in the archive. entries.sort_by(|a, b| a.0.cmp(&b.0)); for (file_name, path) in entries { let child_pkg = format!("{package_filename}/{file_name}"); @@ -742,6 +749,7 @@ impl WhlFile { .start_file(zip_arcname, opts) .with_context(|| format!("starting zip entry {zip_arcname}"))?; + // Write file to the zip archive while computing its SHA-256 digest and byte length. let mut sha = Sha256::new(); let mut size: u64 = 0; loop { @@ -788,6 +796,7 @@ impl WhlFile { /// `RECORD` text. pub fn add_recordfile(&mut self) -> Result { let record_path = self.distinfo_path("RECORD"); + // Quote only when necessary (e.g. for filenames with commas). let mut wtr = csv::WriterBuilder::new() .has_headers(false) .terminator(csv::Terminator::Any(b'\n')) From 5be4e987330d03778621378f961f4b5137be04b3 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 11:35:46 -0800 Subject: [PATCH 3/7] tests: cover remaining wheel_test cases in wheelmaker_test.rs Add Rust unit test coverage for repeated --strip_path_prefix flags in priority order (including prefixes without trailing slashes so RECORD and zip entries strip leading slashes), out-of-order --data_files, --extra_distinfo_file, and directory children, single-semicolon inline Requires-Dist markers, and omitted --description_file fallback to UNKNOWN. --- tests/wheelmaker/wheelmaker_test.rs | 123 +++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 2 deletions(-) diff --git a/tests/wheelmaker/wheelmaker_test.rs b/tests/wheelmaker/wheelmaker_test.rs index faf5048d6d..7f51fc5111 100644 --- a/tests/wheelmaker/wheelmaker_test.rs +++ b/tests/wheelmaker/wheelmaker_test.rs @@ -469,6 +469,7 @@ fn test_end_to_end_customized_wheel_and_record() { let sub_dir = tmp.path().join("someDir"); fs::create_dir_all(&sub_dir).expect("sub_dir should be creatable"); + fs::write(sub_dir.join("zed.py"), b"y = 2\n").expect("zed.py should be writable"); fs::write(sub_dir.join("foo.py"), b"x = 1\n").expect("foo.py should be writable"); let input_list_path = tmp.path().join("inputs.txt"); @@ -568,9 +569,13 @@ fn test_end_to_end_customized_wheel_and_record() { "--entry_points_file", ep_file.to_str().expect("ep_file path should be UTF-8"), "--extra_distinfo_file", + &format!("README;{}", desc_file.display()), + "--extra_distinfo_file", &format!("NOTICE;{}", notice_file.display()), "--data_files", &format!("scripts/NOTICE;{}", notice_file.display()), + "--data_files", + &format!("data/README.md;{}", desc_file.display()), ]) .expect("customized wheel args should parse"), ); @@ -592,11 +597,14 @@ fn test_end_to_end_customized_wheel_and_record() { "pkg/lib/data,with,commas.txt", "pkg/lib/mod.pyi", "pkg/someDir/foo.py", + "pkg/someDir/zed.py", "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/WHEEL", "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/METADATA", "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/entry_points.txt", + "file_name_escaping-0.0.1rc1+ubuntu.r7.data/data/README.md", "file_name_escaping-0.0.1rc1+ubuntu.r7.data/scripts/NOTICE", "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/NOTICE", + "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/README", "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/RECORD", ] ); @@ -633,7 +641,7 @@ fn test_end_to_end_customized_wheel_and_record() { let record_text = by_name["file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/RECORD"].text(); let record_lines: Vec<&str> = record_text.lines().collect(); - assert_eq!(record_lines.len(), 9); + assert_eq!(record_lines.len(), 12); let mut sha = Sha256::new(); sha.update(b"hello world\n"); let expected_first = format!( @@ -642,7 +650,7 @@ fn test_end_to_end_customized_wheel_and_record() { ); assert_eq!(record_lines[0], expected_first); assert_eq!( - record_lines[8], + record_lines[11], "file_name_escaping-0.0.1rc1+ubuntu.r7.dist-info/RECORD,," ); } @@ -793,6 +801,15 @@ fn test_stamping_semantics_and_empty_requires_and_no_compress() { fs::read_to_string(&half_name).expect("half_stamped.name should be readable"), "my_pkg{build_user}-0.1.0+0.1.build.timestamp-py3-none-any.whl" ); + let half_entries: HashMap = read_zip_entries(&half_whl) + .into_iter() + .map(|e| (e.name.clone(), e)) + .collect(); + assert!( + half_entries["my_pkg{build_user}-0.1.0+0.1.build.timestamp.dist-info/METADATA"] + .text() + .ends_with("\n\nUNKNOWN\n") + ); } #[test] @@ -817,6 +834,7 @@ fn test_build_tag_inline_requires_and_duplicate_inputs() { "Metadata-Version: 2.1\n", "Name: Demo-Pkg\n", "Requires-Dist: extra_requires[example]==0.0.1\n", + "Requires-Dist: pytest; python_version != \"3.8\"\n", "Requires-Dist: six>=1.16.0,!=1.16.1; python_version>='3.8'; extra == 'dev'\n", "Provides-Extra: dev\n", "Requires-Dist: @{}; extra == 'dev'\n", @@ -892,6 +910,7 @@ fn test_build_tag_inline_requires_and_duplicate_inputs() { "Metadata-Version: 2.1\n", "Name: Demo-Pkg\n", "Requires-Dist: extra_requires[example]==0.0.1\n", + "Requires-Dist: pytest; python_full_version != '3.8.*'\n", "Requires-Dist: six!=1.16.1,>=1.16.0; ", "python_full_version >= '3.8' and extra == 'dev'\n", "Provides-Extra: dev\n", @@ -902,6 +921,106 @@ fn test_build_tag_inline_requires_and_duplicate_inputs() { ); } +#[test] +fn test_multi_strip_path_prefix_order_and_no_leading_slash_in_record() { + let tmp = TempDir::new("multi_prefix"); + let mod_file = tmp.path().join("mod.py"); + let main_file = tmp.path().join("main.py"); + fs::write(&mod_file, b"x = 1\n").expect("mod.py should be writable"); + fs::write(&main_file, b"y = 2\n").expect("main.py should be writable"); + + let metadata_file = tmp.path().join("metadata.txt"); + fs::write(&metadata_file, "Metadata-Version: 2.1\nName: roots\n") + .expect("metadata.txt should be writable"); + + let build_with_prefixes = |tag: &str, prefixes: &[&str]| -> Vec { + let out_whl = tmp.path().join(format!("{tag}.whl")); + let mut args = vec![ + "--name".to_string(), + "roots".to_string(), + "--version".to_string(), + "0.0.1".to_string(), + "--out".to_string(), + out_whl + .to_str() + .expect("out_whl should be UTF-8") + .to_string(), + "--metadata_file".to_string(), + metadata_file + .to_str() + .expect("metadata_file should be UTF-8") + .to_string(), + "--input_file".to_string(), + format!("examples/wheel/lib/mod.py;{}", mod_file.display()), + "--input_file".to_string(), + format!("examples/wheel/main.py;{}", main_file.display()), + ]; + for prefix in prefixes { + args.push(format!("--strip_path_prefix={prefix}")); + } + let opts = unwrap_run_options(parse_args(args).expect("prefix args should parse")); + build_wheel(&opts).expect("build_wheel should succeed"); + let entries = read_zip_entries(&out_whl); + let record = entries + .iter() + .find(|e| e.name == "roots-0.0.1.dist-info/RECORD") + .expect("RECORD entry should exist") + .text(); + for line in record.lines() { + assert!( + !line.starts_with('/'), + "RECORD line must not start with '/': {line}" + ); + } + entries + }; + + // Stripping `examples` (without a trailing `/`) leaves a leading `/` in `arcname_from`, which + // `WhlFile` must strip in both zip entry headers and `RECORD`. + let single = build_with_prefixes("single", &["examples"]); + let single_names: Vec<&str> = single.iter().map(|e| e.name.as_str()).collect(); + assert_eq!( + single_names, + vec![ + "wheel/lib/mod.py", + "wheel/main.py", + "roots-0.0.1.dist-info/WHEEL", + "roots-0.0.1.dist-info/METADATA", + "roots-0.0.1.dist-info/RECORD", + ] + ); + + // More specific prefix first strips `examples/wheel/lib` on `mod.py` and `examples/wheel` on + // `main.py`. + let specific_first = + build_with_prefixes("specific_first", &["examples/wheel/lib", "examples/wheel"]); + let specific_names: Vec<&str> = specific_first.iter().map(|e| e.name.as_str()).collect(); + assert_eq!( + specific_names, + vec![ + "mod.py", + "main.py", + "roots-0.0.1.dist-info/WHEEL", + "roots-0.0.1.dist-info/METADATA", + "roots-0.0.1.dist-info/RECORD", + ] + ); + + // Broader prefix first wins for both entries, leaving `lib/mod.py` and `main.py`. + let broad_first = build_with_prefixes("broad_first", &["examples/wheel", "examples/wheel/lib"]); + let broad_names: Vec<&str> = broad_first.iter().map(|e| e.name.as_str()).collect(); + assert_eq!( + broad_names, + vec![ + "lib/mod.py", + "main.py", + "roots-0.0.1.dist-info/WHEEL", + "roots-0.0.1.dist-info/METADATA", + "roots-0.0.1.dist-info/RECORD", + ] + ); +} + #[test] fn test_help_and_errors() { assert_eq!( From d1a8c6042be4a4761755bfed31c2e6ad2cd694cf Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 12:00:22 -0800 Subject: [PATCH 4/7] refactor(wheel): switch flate2 backend to zlib-rs Use `zlib-rs` with `runtime_detection` instead of `miniz_oxide` as `zip`'s pure-Rust DEFLATE backend so compressed large wheels outpace C `zlib` while keeping cross-compiled static `musl` builds free of C dependencies. --- crates/Cargo.Bazel.lock | 165 +++------------------------------ crates/Cargo.lock | 23 ----- crates/Cargo.toml | 11 ++- examples/wheel/test_publish.py | 2 +- examples/wheel/wheel_test.py | 16 ++-- 5 files changed, 29 insertions(+), 188 deletions(-) diff --git a/crates/Cargo.Bazel.lock b/crates/Cargo.Bazel.lock index 203ce3fd40..f713074acc 100644 --- a/crates/Cargo.Bazel.lock +++ b/crates/Cargo.Bazel.lock @@ -1,46 +1,6 @@ { - "checksum": "8e165a9ec4f3cc11a7107ce46a496182b8693e631158f49a6e6c6cfd868452e7", + "checksum": "2d0ce215f26718cc18a9b0d2ec186981b34870f61dd4e7fbe3e24330778493bc", "crates": { - "adler2 2.0.1": { - "name": "adler2", - "version": "2.0.1", - "package_url": "https://github.com/oyvindln/adler2", - "repository": { - "Http": { - "url": "https://static.crates.io/crates/adler2/2.0.1/download", - "sha256": "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - } - }, - "targets": [ - { - "Library": { - "crate_name": "adler2", - "crate_root": "src/lib.rs", - "srcs": { - "allow_empty": true, - "include": [ - "**/*.rs" - ] - } - } - } - ], - "library_target_name": "adler2", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "edition": "2021", - "version": "2.0.1" - }, - "license": "0BSD OR MIT OR Apache-2.0", - "license_ids": [ - "0BSD", - "Apache-2.0", - "MIT" - ], - "license_file": "LICENSE-0BSD" - }, "aho-corasick 1.1.5": { "name": "aho-corasick", "version": "1.1.5", @@ -1110,22 +1070,17 @@ "crate_features": { "common": [ "any_impl", - "default", - "miniz_oxide", + "any_zlib", "runtime_detection", - "rust_backend" + "zlib-rs" ], "selects": {} }, "deps": { "common": [ { - "id": "crc32fast 1.5.4", - "target": "crc32fast" - }, - { - "id": "miniz_oxide 0.9.1", - "target": "miniz_oxide" + "id": "zlib-rs 0.6.8", + "target": "zlib_rs" } ], "selects": {} @@ -2354,68 +2309,6 @@ ], "license_file": "LICENSE-MIT" }, - "miniz_oxide 0.9.1": { - "name": "miniz_oxide", - "version": "0.9.1", - "package_url": "https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide", - "repository": { - "Http": { - "url": "https://static.crates.io/crates/miniz_oxide/0.9.1/download", - "sha256": "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" - } - }, - "targets": [ - { - "Library": { - "crate_name": "miniz_oxide", - "crate_root": "src/lib.rs", - "srcs": { - "allow_empty": true, - "include": [ - "**/*.rs" - ] - } - } - } - ], - "library_target_name": "miniz_oxide", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "crate_features": { - "common": [ - "default", - "simd", - "simd-adler32", - "with-alloc" - ], - "selects": {} - }, - "deps": { - "common": [ - { - "id": "adler2 2.0.1", - "target": "adler2" - }, - { - "id": "simd-adler32 0.3.10", - "target": "simd_adler32" - } - ], - "selects": {} - }, - "edition": "2021", - "version": "0.9.1" - }, - "license": "MIT OR Zlib OR Apache-2.0", - "license_ids": [ - "Apache-2.0", - "MIT", - "Zlib" - ], - "license_file": "LICENSE" - }, "nix 0.31.3": { "name": "nix", "version": "0.31.3", @@ -3759,44 +3652,6 @@ ], "license_file": "LICENSE-APACHE" }, - "simd-adler32 0.3.10": { - "name": "simd-adler32", - "version": "0.3.10", - "package_url": "https://github.com/mcountryman/simd-adler32", - "repository": { - "Http": { - "url": "https://static.crates.io/crates/simd-adler32/0.3.10/download", - "sha256": "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" - } - }, - "targets": [ - { - "Library": { - "crate_name": "simd_adler32", - "crate_root": "src/lib.rs", - "srcs": { - "allow_empty": true, - "include": [ - "**/*.rs" - ] - } - } - } - ], - "library_target_name": "simd_adler32", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "edition": "2018", - "version": "0.3.10" - }, - "license": "MIT", - "license_ids": [ - "MIT" - ], - "license_file": "LICENSE.md" - }, "smallvec 1.16.5": { "name": "smallvec", "version": "1.16.5", @@ -5238,7 +5093,8 @@ "crate_features": { "common": [ "_deflate-any", - "deflate-flate2" + "deflate-flate2", + "deflate-flate2-zlib-rs" ], "selects": {} }, @@ -5312,6 +5168,13 @@ "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "rust-allocator", + "std" + ], + "selects": {} + }, "edition": "2021", "version": "0.6.8" }, diff --git a/crates/Cargo.lock b/crates/Cargo.lock index 4445a45432..1b43554c29 100644 --- a/crates/Cargo.lock +++ b/crates/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - [[package]] name = "aho-corasick" version = "1.1.5" @@ -173,7 +167,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" dependencies = [ "crc32fast", - "miniz_oxide", "zlib-rs", ] @@ -363,16 +356,6 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" -[[package]] -name = "miniz_oxide" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" -dependencies = [ - "adler2", - "simd-adler32", -] - [[package]] name = "nix" version = "0.31.3" @@ -567,12 +550,6 @@ dependencies = [ "digest", ] -[[package]] -name = "simd-adler32" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" - [[package]] name = "smallvec" version = "1.16.5" diff --git a/crates/Cargo.toml b/crates/Cargo.toml index 6871f66290..d11365a491 100644 --- a/crates/Cargo.toml +++ b/crates/Cargo.toml @@ -18,19 +18,20 @@ anyhow = "1.0.104" argfile = "1.0.0" base64 = "0.23.1" csv = "1.4.0" -# Transitive dep of zip: zip's `deflate-flate2` leaves the backend unset, so a -# top-level pin keeps flate2 on its default pure-Rust backend. -flate2 = "1.1.11" +# Transitive dep of zip: disable default features (`rust_backend` pulls in +# unused `miniz_oxide`) and enable `runtime_detection` so `zlib-rs` enables +# runtime SIMD feature detection (`zip` disables `flate2` default features). +flate2 = { version = "1.1.11", default-features = false, features = ["runtime_detection"] } lexopt = "0.3.2" pep440_rs = "0.7.3" pep508_rs = "0.9.2" regex = "1.13.1" sha2 = "0.11.1" # Disable default features (C zstd-sys bindings plus unused compression, -# encryption, and time subsystems) and enable only `deflate-flate2`. +# encryption, and time subsystems) and enable only `deflate-flate2-zlib-rs`. # NOTE: Keep below 9.1.0; zip >= 9.1.0 adds mandatory target-conditional OS deps # (getrandom, windows-sys, libc) that fail on powerpc64le-unknown-linux-musl # until rules_rust defines a powerpc64le @rules_rust//rust/platform # config_setting. -zip = { version = "~9.0.5", default-features = false, features = ["deflate-flate2"] } +zip = { version = "~9.0.5", default-features = false, features = ["deflate-flate2-zlib-rs"] } # keep-sorted end diff --git a/examples/wheel/test_publish.py b/examples/wheel/test_publish.py index fa8251664b..43f368eb83 100644 --- a/examples/wheel/test_publish.py +++ b/examples/wheel/test_publish.py @@ -15,7 +15,7 @@ _EXPECTED_WHEEL_SHA256 = { # keep-sorted start "python": "ef5afd9f6c3ff569ef7e5b2799d3a2ec9675d029414f341e0abd7254d6b9a25d", - "rust": "7b0ddefcee45535ba6808761e540332fe5488deb53ff37f5006416a9fd1b48ef", + "rust": "abb3ff8d5bb5142cdb476b46e91f586043e10a540170ed66050fbc5c1e19ae32", # keep-sorted end } diff --git a/examples/wheel/wheel_test.py b/examples/wheel/wheel_test.py index b93d09e0a7..76917319de 100644 --- a/examples/wheel/wheel_test.py +++ b/examples/wheel/wheel_test.py @@ -100,7 +100,7 @@ def test_py_library_wheel(self): { # keep-sorted start "python": "ef5afd9f6c3ff569ef7e5b2799d3a2ec9675d029414f341e0abd7254d6b9a25d", - "rust": "7b0ddefcee45535ba6808761e540332fe5488deb53ff37f5006416a9fd1b48ef", + "rust": "abb3ff8d5bb5142cdb476b46e91f586043e10a540170ed66050fbc5c1e19ae32", # keep-sorted end }, ) @@ -131,7 +131,7 @@ def test_py_package_wheel(self): { # keep-sorted start "python": "7322902ab63fd702afb9730843496637058b5d7449208c624875d06d191d386e", - "rust": "01eacc04389891449feadac17a3fabcb8258398518327671c9f031a760293db0", + "rust": "6281a39185200fb7028a376a915b5b7cd636f007f4151c1805ff0445a4b4d580", # keep-sorted end }, ) @@ -233,7 +233,7 @@ def test_customized_wheel(self): { # keep-sorted start "python": "6d08fbb30864cee89396e7857c910c92bec56b6586d40a64b796b4812af15fbf", - "rust": "1d34e7c704448673a6a4458b887f4e70f6874a7646778828c079e0ac2e454db1", + "rust": "d13f280f8340e0faf6bd776f97ed8e0b2ced2cea338a33f32d6ab56aac068254", # keep-sorted end }, ) @@ -311,7 +311,7 @@ def test_custom_package_root_wheel(self): { # keep-sorted start "python": "0b5a35251ad35fd9e14f3f7e77993f59a7341268f24fb0a255b403cee60d429e", - "rust": "1b45e76f5618d7125b8a0ea0fd4de841c250575a73869fb67293d95325f763b8", + "rust": "9a40c04d9b04039286f738f6ad7386d2cab180072e560f826a0a322a6c342990", # keep-sorted end }, ) @@ -351,7 +351,7 @@ def test_custom_package_root_multi_prefix_wheel(self): { # keep-sorted start "python": "437127690584a035dc37542f64c38d1a6d6652655afc81f5a9472706343aae23", - "rust": "512f75085e9b0919daeaef32d0ebc5aa419bc23c65641a32ea38a72295e61a06", + "rust": "8763921f3936b556ae0a934f6318216fe3c4ab57c765041398369b54bfb24502", # keep-sorted end }, ) @@ -391,7 +391,7 @@ def test_custom_package_root_multi_prefix_reverse_order_wheel(self): { # keep-sorted start "python": "265cc2ba4c99d0b62f1922f357de961f15f416bcee93ff307e4d4f04e4c067a3", - "rust": "510aa10aa0daa69e9903c946b046d6b998cc85209c715333ffc412e324880833", + "rust": "76e5d5a77b8a3c5305692b6596aacdfc01e5e4d40bfdfc21141741995b75ebd4", # keep-sorted end }, ) @@ -422,7 +422,7 @@ def test_python_requires_wheel(self): { # keep-sorted start "python": "cb1d0bf64df1cbf23b7d4473a1c113cedbbea0d23209cdb4d2e5fe2edc68ceec", - "rust": "cc1060cccda6e422ec8bf92006e0c0a0ae7986d637814144de4dedb87fb448c6", + "rust": "80ef6fadc4402593d1b6ea8d00efe1ecb24678c294d61454708aab6ac584e930", # keep-sorted end }, ) @@ -493,7 +493,7 @@ def test_rule_creates_directory_and_is_included_in_wheel(self): { # keep-sorted start "python": "2358a8ee58dd7ed1a89862e368a0eb00e83ec5de28995ecf0f3c38c2524102dc", - "rust": "1c0e3c6f2f529466c5f2fb93d1a1a21da47e4695571be738e794e5dde484e756", + "rust": "31287051700911cfd754df9e63f3849a744497b8c2159a196a88276d97ea9922", # keep-sorted end }, ) From 316bd85d0534a81c5a12065007d0650f5f29ab54 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 12:08:36 -0800 Subject: [PATCH 5/7] refactor(wheel): simplify line iteration and document fallible APIs Iterate lines directly with `str::lines` instead of pre-allocating `\r\n`-normalized strings before line splitting, express requirements file filtering as an iterator chain, and document `# Errors` conditions and `Path::parent` behavior. --- crates/wheelmaker/src/lib.rs | 91 ++++++++++++++++------------- tests/wheelmaker/wheelmaker_test.rs | 15 ++--- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/crates/wheelmaker/src/lib.rs b/crates/wheelmaker/src/lib.rs index d9d50b7840..f63f48f726 100644 --- a/crates/wheelmaker/src/lib.rs +++ b/crates/wheelmaker/src/lib.rs @@ -2,8 +2,8 @@ //! //! Mirrors `tools/wheelmaker.py` with two intentional differences stemming from its pure-Rust //! dependencies: -//! * Compressed `.whl` archives use `flate2`'s pure-Rust DEFLATE backend rather than C `zlib`, so -//! compressed byte streams (and outer `.whl` file digests) differ while archive entries and +//! * Compressed `.whl` archives use `flate2`'s pure-Rust `zlib-rs` backend rather than C `zlib`, +//! so compressed byte streams (and outer `.whl` file digests) differ while archive entries and //! `RECORD` SHA-256 digests are identical. //! * `Requires-Dist` lines parsed through `pep508_rs` normalize distribution names (PEP 503), //! extra names (PEP 685), and environment markers (algebraic PEP 508 simplification). @@ -258,6 +258,11 @@ fn format_requirement(req: &pep508_rs::Requirement) -> S /// /// Uses `pep508_rs`, which normalizes package names (PEP 503), extra names (PEP 685), and /// environment markers. +/// +/// # Errors +/// +/// Returns an error if `reqs_text` is not a valid PEP 508 requirement or `extra` is not a valid +/// PEP 508 marker expression. pub fn get_new_requirement_line(reqs_text: &str, extra: &str) -> Result { let mut req = pep508_rs::Requirement::::from_str(reqs_text.trim()) .with_context(|| format!("parsing requirement {reqs_text:?}"))?; @@ -285,25 +290,24 @@ pub fn resolve_stamp_with_lines(argument: &str, status_lines: &[String]) -> Stri resolved } -fn read_text_universal_newlines(path: &Path) -> Result { - let raw = fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?; - Ok(raw.replace("\r\n", "\n")) +fn read_text(path: &Path) -> Result { + fs::read_to_string(path).with_context(|| format!("reading {}", path.display())) } /// Expands `Requires-Dist:` lines in `metadata` (both inline requirements with `;` markers and /// `@file` requirement-file directives). +/// +/// # Errors +/// +/// Returns an error if a referenced `@file` requirements file cannot be read, or if an inline +/// requirement, extra marker, or requirements-file entry is not valid PEP 508 syntax. pub fn expand_metadata_requires(metadata: &str) -> Result { - let normalized = metadata.replace("\r\n", "\n"); - let mut out = String::with_capacity(normalized.len()); - - for raw_line in normalized.split_inclusive('\n') { - let (meta_line, line_ending) = match raw_line.strip_suffix('\n') { - Some(line) => (line, "\n"), - None => (raw_line, ""), - }; + let mut out = String::with_capacity(metadata.len()); + for meta_line in metadata.lines() { let Some(after_prefix) = meta_line.strip_prefix("Requires-Dist: ") else { - out.push_str(raw_line); + out.push_str(meta_line); + out.push('\n'); continue; }; @@ -311,13 +315,14 @@ pub fn expand_metadata_requires(metadata: &str) -> Result { // Normal inline requirement: only re-format when a `;` marker/extra is present, // matching `tools/wheelmaker.py`. let Some((package, extra)) = after_prefix.rsplit_once(';') else { - out.push_str(raw_line); + out.push_str(meta_line); + out.push('\n'); continue; }; let formatted = get_new_requirement_line(package, extra.trim()) .with_context(|| format!("in metadata line {meta_line:?}"))?; out.push_str(&formatted); - out.push_str(line_ending); + out.push('\n'); continue; }; @@ -326,28 +331,23 @@ pub fn expand_metadata_requires(metadata: &str) -> Result { Some((f, e)) => (f, e.trim()), None => (after_at, ""), }; - let req_file_text = read_text_universal_newlines(Path::new(file_part))?; - let mut reqs = Vec::new(); - for reqs_line in req_file_text.lines() { - let reqs_text = reqs_line.trim(); - if reqs_text.is_empty() || reqs_text.starts_with('#') || reqs_text.starts_with('-') { - continue; - } - // Strip inline comments. - let reqs_text = match reqs_text.split_once('#') { - Some((before_comment, _)) => before_comment, - None => reqs_text, - }; + let req_file_text = read_text(Path::new(file_part))?; + // If the referenced requirements file has no requirements, nothing is pushed and the + // directive line is dropped entirely. + for reqs_text in req_file_text + .lines() + .map(str::trim) + .filter(|line| !(line.is_empty() || line.starts_with(['#', '-']))) + .map(|line| { + // Strip inline comments. + line.split_once('#') + .map_or(line, |(before_comment, _)| before_comment) + }) + { let formatted = get_new_requirement_line(reqs_text, extra) .with_context(|| format!("in requirements file {file_part}"))?; - reqs.push(formatted); - } - - // If the referenced requirements file has no requirements, drop the directive line - // (including its trailing newline) entirely. - if !reqs.is_empty() { - out.push_str(&reqs.join("\n")); - out.push_str(line_ending); + out.push_str(&formatted); + out.push('\n'); } } @@ -355,6 +355,8 @@ pub fn expand_metadata_requires(metadata: &str) -> Result { } fn create_parent_dir(path: &Path) -> Result<()> { + // `Path::parent` returns `Some("")` for bare filenames like `"foo.whl"`, and + // `fs::create_dir_all("")` fails with `NotFound`. if let Some(parent) = path.parent() && !parent.as_os_str().is_empty() { @@ -372,7 +374,7 @@ fn create_parent_dir(path: &Path) -> Result<()> { fn collect_sorted_inputs(options: &Options) -> Result> { let mut input_files = options.input_file.clone(); for list_path in &options.input_file_list { - let content = read_text_universal_newlines(list_path)?; + let content = read_text(list_path)?; for line in content.lines() { if line.is_empty() { continue; @@ -402,8 +404,8 @@ fn resolve_name_and_version(options: &Options) -> Result<(String, String)> { else { return Ok((options.name.clone(), options.version.clone())); }; - let volatile_text = read_text_universal_newlines(volatile_path)?; - let stable_text = read_text_universal_newlines(stable_path)?; + let volatile_text = read_text(volatile_path)?; + let stable_text = read_text(stable_path)?; let status_lines: Vec = volatile_text .lines() .chain(stable_text.lines()) @@ -438,11 +440,18 @@ pub fn build_wheel(options: &Options) -> Result<()> { whl.add_string(&maker.distinfo_path("WHEEL"), wheel_contents.as_bytes())?; let description = match &options.description_file { - Some(desc_path) => Some(read_text_universal_newlines(desc_path)?), + Some(desc_path) => { + let mut desc = read_text(desc_path)?; + // Normalize CRLF on Windows so `/METADATA` stays LF-only across platforms. + if desc.contains("\r\n") { + desc = desc.replace("\r\n", "\n"); + } + Some(desc) + } None => None, }; - let raw_metadata = read_text_universal_newlines(&options.metadata_file)?; + let raw_metadata = read_text(&options.metadata_file)?; let expanded_metadata = expand_metadata_requires(&raw_metadata)?; let final_metadata = maker.format_metadata(&expanded_metadata, description.as_deref())?; whl.add_string(&maker.distinfo_path("METADATA"), final_metadata.as_bytes())?; diff --git a/tests/wheelmaker/wheelmaker_test.rs b/tests/wheelmaker/wheelmaker_test.rs index 7f51fc5111..2481cd3cdc 100644 --- a/tests/wheelmaker/wheelmaker_test.rs +++ b/tests/wheelmaker/wheelmaker_test.rs @@ -428,18 +428,19 @@ fn test_escaping_and_pep440_normalization() { fn test_expand_metadata_requires_shared_file_with_and_without_extra() { let tmp = TempDir::new("shared_reqs"); let reqs_file = tmp.path().join("shared.txt"); - fs::write(&reqs_file, "tomli>=2.0.0\nstarlark # inline comment\n") + fs::write(&reqs_file, "tomli>=2.0.0\r\nstarlark # inline comment\r\n") .expect("shared.txt should be writable"); // Regression check: when the same @file path appears both bare and with `; extra == '...'`, - // expanding the bare directive must not corrupt the extra directive's line. + // expanding the bare directive must not corrupt the extra directive's line; `\r\n` inputs are + // handled directly via `str::lines` and emitted with `\n`. let raw = format!( concat!( - "Metadata-Version: 2.1\n", - "Name: shared\n", - "Requires-Dist: @{reqs}\n", - "Provides-Extra: dev\n", - "Requires-Dist: @{reqs}; extra == 'dev'\n", + "Metadata-Version: 2.1\r\n", + "Name: shared\r\n", + "Requires-Dist: @{reqs}\r\n", + "Provides-Extra: dev\r\n", + "Requires-Dist: @{reqs}; extra == 'dev'\r\n", ), reqs = reqs_file.display(), ); From 2bcd3e2dcc5e744bd2e49ab55f6344bc20759bd8 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 12:19:59 -0800 Subject: [PATCH 6/7] refactor(wheel): inline input deduplication and stream CRLF descriptions Fold `get_files_to_package` directly into `collect_sorted_inputs` so entries go straight into the deduplicating `HashMap` before sorting, and normalize `\r\n` while appending the description into `METADATA` in `format_metadata` instead of allocating an extra string in `build_wheel`. --- crates/wheelmaker/src/lib.rs | 49 +++++++++++------------------ tests/wheelmaker/wheelmaker_test.rs | 8 +++-- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/crates/wheelmaker/src/lib.rs b/crates/wheelmaker/src/lib.rs index f63f48f726..e1c4876c73 100644 --- a/crates/wheelmaker/src/lib.rs +++ b/crates/wheelmaker/src/lib.rs @@ -201,19 +201,6 @@ pub fn serialize_digest(sha256_bytes: &[u8]) -> String { ) } -/// Collects `(package_path, real_path)` pairs into a map keyed by `package_path` (later entries -/// win on duplicate archive destinations, matching `tools/wheelmaker.py`). -/// -/// Keys (`package_path`) are relative to the wheel root before prefix rewriting; values -/// (`real_path`) are filesystem paths relative to CWD or absolute. -pub fn get_files_to_package(input_files: &[(String, PathBuf)]) -> HashMap { - let mut files = HashMap::with_capacity(input_files.len()); - for (package_path, real_path) in input_files { - files.insert(package_path.clone(), real_path.clone()); - } - files -} - fn format_requirement(req: &pep508_rs::Requirement) -> String { let mut out = format!("Requires-Dist: {}", req.name); if !req.extras.is_empty() { @@ -367,12 +354,13 @@ fn create_parent_dir(path: &Path) -> Result<()> { } /// Collects `--input_file` and `--input_file_list` entries into archive-path-sorted -/// `(package_path, real_path)` pairs. +/// `(package_path, real_path)` pairs (later entries win on duplicate `package_path` keys, +/// matching `tools/wheelmaker.py`). /// /// Each `package_path` is relative to the wheel root before prefix rewriting; each `real_path` is /// relative to CWD or absolute. fn collect_sorted_inputs(options: &Options) -> Result> { - let mut input_files = options.input_file.clone(); + let mut files: HashMap = options.input_file.iter().cloned().collect(); for list_path in &options.input_file_list { let content = read_text(list_path)?; for line in content.lines() { @@ -386,11 +374,10 @@ fn collect_sorted_inputs(options: &Options) -> Result> { list_path.display() ); }; - input_files.push((pkg.to_string(), PathBuf::from(real))); + files.insert(pkg.to_string(), PathBuf::from(real)); } } - let mut sorted_files: Vec<(String, PathBuf)> = - get_files_to_package(&input_files).into_iter().collect(); + let mut sorted_files: Vec<(String, PathBuf)> = files.into_iter().collect(); // Sort the files for reproducible order in the archive. sorted_files.sort_unstable_by(|a, b| a.0.cmp(&b.0)); Ok(sorted_files) @@ -439,17 +426,11 @@ pub fn build_wheel(options: &Options) -> Result<()> { let wheel_contents = maker.wheelfile_contents(); whl.add_string(&maker.distinfo_path("WHEEL"), wheel_contents.as_bytes())?; - let description = match &options.description_file { - Some(desc_path) => { - let mut desc = read_text(desc_path)?; - // Normalize CRLF on Windows so `/METADATA` stays LF-only across platforms. - if desc.contains("\r\n") { - desc = desc.replace("\r\n", "\n"); - } - Some(desc) - } - None => None, - }; + let description = options + .description_file + .as_deref() + .map(read_text) + .transpose()?; let raw_metadata = read_text(&options.metadata_file)?; let expanded_metadata = expand_metadata_requires(&raw_metadata)?; @@ -946,7 +927,15 @@ impl WheelMaker { out.push_str(&format!("Version: {}\n\n", self.version)); // setuptools inserts `UNKNOWN` as the description when none is provided. match description { - Some(desc) if !desc.is_empty() => out.push_str(desc), + Some(desc) if !desc.is_empty() => { + // Normalize CRLF on Windows while appending directly into `out`. + for (i, chunk) in desc.split("\r\n").enumerate() { + if i > 0 { + out.push('\n'); + } + out.push_str(chunk); + } + } _ => out.push_str("UNKNOWN"), } out.push('\n'); diff --git a/tests/wheelmaker/wheelmaker_test.rs b/tests/wheelmaker/wheelmaker_test.rs index 2481cd3cdc..218a61bdc4 100644 --- a/tests/wheelmaker/wheelmaker_test.rs +++ b/tests/wheelmaker/wheelmaker_test.rs @@ -703,8 +703,11 @@ fn test_stamping_semantics_and_empty_requires_and_no_compress() { .expect("metadata.txt should be writable"); let desc_file = tmp.path().join("desc.txt"); - fs::write(&desc_file, "Body mentions {BUILD_TIMESTAMP} literally.") - .expect("desc.txt should be writable"); + fs::write( + &desc_file, + "Line one.\r\nBody mentions {BUILD_TIMESTAMP} literally.", + ) + .expect("desc.txt should be writable"); let out_whl = tmp.path().join("stamped.whl"); let name_file = tmp.path().join("stamped.name"); @@ -769,6 +772,7 @@ fn test_stamping_semantics_and_empty_requires_and_no_compress() { "Name: my_pkgalice\n", "Summary: Literal {BUILD_USER} placeholder\n", "Version: 0.1.123456\n\n", + "Line one.\n", "Body mentions {BUILD_TIMESTAMP} literally.\n", ) ); From 44f0311c409e82bf07285c0cc394605350b45b18 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 12:28:53 -0800 Subject: [PATCH 7/7] refactor(wheel): drop redundant empty-parent check before create_dir_all `std::fs::create_dir_all("")` already succeeds as a no-op, so `create_parent_dir` does not need to guard against `!parent.as_os_str().is_empty()` when `--out` or `--name_file` is a bare relative filename. Add a subprocess test exercising bare relative output paths in the child working directory. --- crates/wheelmaker/src/lib.rs | 6 +----- tests/shrubbery/shrubbery_test.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/crates/wheelmaker/src/lib.rs b/crates/wheelmaker/src/lib.rs index e1c4876c73..a3a397c3c1 100644 --- a/crates/wheelmaker/src/lib.rs +++ b/crates/wheelmaker/src/lib.rs @@ -342,11 +342,7 @@ pub fn expand_metadata_requires(metadata: &str) -> Result { } fn create_parent_dir(path: &Path) -> Result<()> { - // `Path::parent` returns `Some("")` for bare filenames like `"foo.whl"`, and - // `fs::create_dir_all("")` fails with `NotFound`. - if let Some(parent) = path.parent() - && !parent.as_os_str().is_empty() - { + if let Some(parent) = path.parent() { fs::create_dir_all(parent) .with_context(|| format!("creating directory {}", parent.display()))?; } diff --git a/tests/shrubbery/shrubbery_test.rs b/tests/shrubbery/shrubbery_test.rs index 41cf864965..372fa34842 100644 --- a/tests/shrubbery/shrubbery_test.rs +++ b/tests/shrubbery/shrubbery_test.rs @@ -141,4 +141,35 @@ fn test_cli_binary_subprocess() { "unexpected stderr: {}", String::from_utf8_lossy(&bad_out.stderr) ); + + let abs_resolved = + std::path::absolute(&resolved).expect("SHRUBBERY_BIN should resolve to an absolute path"); + let dir = temp_test_dir("subprocess_cwd"); + fs::write( + dir.join("metadata.txt"), + "Metadata-Version: 2.1\nName: pkg\n", + ) + .expect("metadata should be writable"); + let whl_out = Command::new(&abs_resolved) + .current_dir(&dir) + .args([ + "wheelmaker", + "--name=pkg", + "--version=1.0.0", + "--metadata_file=metadata.txt", + "--name_file=wheelname.txt", + ]) + .output() + .expect("shrubbery wheelmaker should run in subprocess cwd"); + assert_eq!( + whl_out.status.code(), + Some(0), + "stderr: {}", + String::from_utf8_lossy(&whl_out.stderr) + ); + assert!(dir.join("pkg-1.0.0-py3-none-any.whl").exists()); + assert_eq!( + fs::read_to_string(dir.join("wheelname.txt")).expect("wheelname.txt should exist"), + "pkg-1.0.0-py3-none-any.whl" + ); }