Skip to content

Commit 062bea7

Browse files
authored
Add auditwheel Warn mode, default to Warn on macOS/Windows (#3121)
1 parent 70ea112 commit 062bea7

File tree

6 files changed

+37
-11
lines changed

6 files changed

+37
-11
lines changed

maturin.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@
253253
"type": "string",
254254
"const": "check"
255255
},
256+
{
257+
"description": "Audit wheel and warn about external libraries, but do not fail or repair",
258+
"type": "string",
259+
"const": "warn"
260+
},
256261
{
257262
"description": "Don't check for manylinux compliance",
258263
"type": "string",

src/auditwheel/audit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub enum AuditWheelMode {
1414
Repair,
1515
/// Check wheel for manylinux compliance, but do not repair
1616
Check,
17+
/// Audit wheel and warn about external libraries, but do not fail or repair
18+
Warn,
1719
/// Don't check for manylinux compliance
1820
Skip,
1921
}
@@ -23,6 +25,7 @@ impl fmt::Display for AuditWheelMode {
2325
match self {
2426
AuditWheelMode::Repair => write!(f, "repair"),
2527
AuditWheelMode::Check => write!(f, "check"),
28+
AuditWheelMode::Warn => write!(f, "warn"),
2629
AuditWheelMode::Skip => write!(f, "skip"),
2730
}
2831
}

src/build_context/builder.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl BuildContextBuilder {
160160
}
161161

162162
let (strip, include_debuginfo, auditwheel) =
163-
Self::resolve_build_flags(strip, &build_options, pyproject);
163+
Self::resolve_build_flags(strip, &build_options, pyproject, &target);
164164

165165
let sbom = Self::resolve_sbom_config(&build_options, pyproject);
166166

@@ -319,6 +319,7 @@ impl BuildContextBuilder {
319319
strip: Option<bool>,
320320
build_options: &BuildOptions,
321321
pyproject: Option<&PyProjectToml>,
322+
target: &Target,
322323
) -> (bool, bool, AuditWheelMode) {
323324
let strip = strip.unwrap_or_else(|| pyproject.map(|x| x.strip()).unwrap_or_default());
324325
let include_debuginfo = if strip && build_options.output.include_debuginfo {
@@ -331,15 +332,20 @@ impl BuildContextBuilder {
331332
};
332333
let skip_auditwheel = pyproject.map(|x| x.skip_auditwheel()).unwrap_or_default()
333334
|| build_options.platform.skip_auditwheel;
335+
let default_mode = if skip_auditwheel {
336+
AuditWheelMode::Skip
337+
} else if target.is_linux() {
338+
AuditWheelMode::Repair
339+
} else {
340+
// macOS and Windows repair support is newer;
341+
// default to Warn so we don't break existing workflows.
342+
AuditWheelMode::Warn
343+
};
334344
let auditwheel = build_options
335345
.platform
336346
.auditwheel
337347
.or_else(|| pyproject.and_then(|x| x.auditwheel()))
338-
.unwrap_or(if skip_auditwheel {
339-
AuditWheelMode::Skip
340-
} else {
341-
AuditWheelMode::Repair
342-
});
348+
.unwrap_or(default_mode);
343349
(strip, include_debuginfo, auditwheel)
344350
}
345351

src/build_context/repair.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,21 @@ impl BuildContext {
165165
}
166166
}
167167

168-
if matches!(self.python.auditwheel, AuditWheelMode::Check) {
169-
bail!(
170-
"Your library requires copying the above external libraries. \
171-
Re-run with `--auditwheel=repair` to copy them."
172-
);
168+
match self.python.auditwheel {
169+
AuditWheelMode::Warn => {
170+
eprintln!(
171+
"⚠️ Warning: Your library requires copying the above external libraries. \
172+
Re-run with `--auditwheel=repair` to copy them into the wheel."
173+
);
174+
return Ok(());
175+
}
176+
AuditWheelMode::Check => {
177+
bail!(
178+
"Your library requires copying the above external libraries. \
179+
Re-run with `--auditwheel=repair` to copy them."
180+
);
181+
}
182+
_ => {}
173183
}
174184

175185
let repairer = self

tests/cmd/build.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Options:
6161
Possible values:
6262
- repair: Audit and repair wheel for manylinux compliance
6363
- check: Check wheel for manylinux compliance, but do not repair
64+
- warn: Audit wheel and warn about external libraries, but do not fail or repair
6465
- skip: Don't check for manylinux compliance
6566

6667
--zig

tests/cmd/publish.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Options:
9999
Possible values:
100100
- repair: Audit and repair wheel for manylinux compliance
101101
- check: Check wheel for manylinux compliance, but do not repair
102+
- warn: Audit wheel and warn about external libraries, but do not fail or repair
102103
- skip: Don't check for manylinux compliance
103104

104105
--zig

0 commit comments

Comments
 (0)