From c0067bf580d8590bf4d3bbefcfec0cf2e62a938d Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 9 Apr 2026 07:53:45 +0800 Subject: [PATCH] Add auditwheel Warn mode, default to Warn on macOS/Windows - Add Warn variant to AuditWheelMode that audits and warns about external libraries without failing or repairing - Change default: Linux remains Repair, macOS and Windows default to Warn since repair support is newer - Update JSON schema with the new warn option --- maturin.schema.json | 5 +++++ src/auditwheel/audit.rs | 3 +++ src/build_context/builder.rs | 18 ++++++++++++------ src/build_context/repair.rs | 20 +++++++++++++++----- tests/cmd/build.stdout | 1 + tests/cmd/publish.stdout | 1 + 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/maturin.schema.json b/maturin.schema.json index 847a3c390..ee339370d 100644 --- a/maturin.schema.json +++ b/maturin.schema.json @@ -253,6 +253,11 @@ "type": "string", "const": "check" }, + { + "description": "Audit wheel and warn about external libraries, but do not fail or repair", + "type": "string", + "const": "warn" + }, { "description": "Don't check for manylinux compliance", "type": "string", diff --git a/src/auditwheel/audit.rs b/src/auditwheel/audit.rs index 1f7fc3cbe..8ac6da9ef 100644 --- a/src/auditwheel/audit.rs +++ b/src/auditwheel/audit.rs @@ -14,6 +14,8 @@ pub enum AuditWheelMode { Repair, /// Check wheel for manylinux compliance, but do not repair Check, + /// Audit wheel and warn about external libraries, but do not fail or repair + Warn, /// Don't check for manylinux compliance Skip, } @@ -23,6 +25,7 @@ impl fmt::Display for AuditWheelMode { match self { AuditWheelMode::Repair => write!(f, "repair"), AuditWheelMode::Check => write!(f, "check"), + AuditWheelMode::Warn => write!(f, "warn"), AuditWheelMode::Skip => write!(f, "skip"), } } diff --git a/src/build_context/builder.rs b/src/build_context/builder.rs index 52472062c..23f0b4916 100644 --- a/src/build_context/builder.rs +++ b/src/build_context/builder.rs @@ -160,7 +160,7 @@ impl BuildContextBuilder { } let (strip, include_debuginfo, auditwheel) = - Self::resolve_build_flags(strip, &build_options, pyproject); + Self::resolve_build_flags(strip, &build_options, pyproject, &target); let sbom = Self::resolve_sbom_config(&build_options, pyproject); @@ -319,6 +319,7 @@ impl BuildContextBuilder { strip: Option, build_options: &BuildOptions, pyproject: Option<&PyProjectToml>, + target: &Target, ) -> (bool, bool, AuditWheelMode) { let strip = strip.unwrap_or_else(|| pyproject.map(|x| x.strip()).unwrap_or_default()); let include_debuginfo = if strip && build_options.output.include_debuginfo { @@ -331,15 +332,20 @@ impl BuildContextBuilder { }; let skip_auditwheel = pyproject.map(|x| x.skip_auditwheel()).unwrap_or_default() || build_options.platform.skip_auditwheel; + let default_mode = if skip_auditwheel { + AuditWheelMode::Skip + } else if target.is_linux() { + AuditWheelMode::Repair + } else { + // macOS and Windows repair support is newer; + // default to Warn so we don't break existing workflows. + AuditWheelMode::Warn + }; let auditwheel = build_options .platform .auditwheel .or_else(|| pyproject.and_then(|x| x.auditwheel())) - .unwrap_or(if skip_auditwheel { - AuditWheelMode::Skip - } else { - AuditWheelMode::Repair - }); + .unwrap_or(default_mode); (strip, include_debuginfo, auditwheel) } diff --git a/src/build_context/repair.rs b/src/build_context/repair.rs index 44c5d2771..e3192b687 100644 --- a/src/build_context/repair.rs +++ b/src/build_context/repair.rs @@ -165,11 +165,21 @@ impl BuildContext { } } - if matches!(self.python.auditwheel, AuditWheelMode::Check) { - bail!( - "Your library requires copying the above external libraries. \ - Re-run with `--auditwheel=repair` to copy them." - ); + match self.python.auditwheel { + AuditWheelMode::Warn => { + eprintln!( + "⚠️ Warning: Your library requires copying the above external libraries. \ + Re-run with `--auditwheel=repair` to copy them into the wheel." + ); + return Ok(()); + } + AuditWheelMode::Check => { + bail!( + "Your library requires copying the above external libraries. \ + Re-run with `--auditwheel=repair` to copy them." + ); + } + _ => {} } let repairer = self diff --git a/tests/cmd/build.stdout b/tests/cmd/build.stdout index 641ab4055..df1d27bb2 100644 --- a/tests/cmd/build.stdout +++ b/tests/cmd/build.stdout @@ -61,6 +61,7 @@ Options: Possible values: - repair: Audit and repair wheel for manylinux compliance - check: Check wheel for manylinux compliance, but do not repair + - warn: Audit wheel and warn about external libraries, but do not fail or repair - skip: Don't check for manylinux compliance --zig diff --git a/tests/cmd/publish.stdout b/tests/cmd/publish.stdout index 2c4b4f843..a6a3b60cc 100644 --- a/tests/cmd/publish.stdout +++ b/tests/cmd/publish.stdout @@ -99,6 +99,7 @@ Options: Possible values: - repair: Audit and repair wheel for manylinux compliance - check: Check wheel for manylinux compliance, but do not repair + - warn: Audit wheel and warn about external libraries, but do not fail or repair - skip: Don't check for manylinux compliance --zig