Skip to content

Commit 8529a37

Browse files
committed
Fix undefined auditwheel policy panic
1 parent c04de80 commit 8529a37

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.codespellrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[codespell]
22
ignore-words-list = crate
3+
skip = ./.git,./target,./test-crates/venvs,./guide/book

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
* Fix docs for `new` and `init` commands in `maturin --help` in [#734](https://github.com/PyO3/maturin/pull/734)
1111
* Add support for x86_64 Haiku in [#735](https://github.com/PyO3/maturin/pull/735)
12+
* Fix undefined auditwheel policy panic in [#740](https://github.com/PyO3/maturin/pull/740)
1213

1314
## [0.12.4] - 2021-12-06
1415

src/auditwheel/audit.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ pub enum AuditWheelError {
3737
/// The elf file isn't manylinux/musllinux compaible. Contains unsupported architecture
3838
#[error("Your library is not {0} compliant because it has unsupported architecture: {1}")]
3939
UnsupportedArchitecture(Policy, String),
40+
/// This platform tag isn't defined by auditwheel yet
41+
#[error("{0} compatibility policy is not defined by auditwheel yet, pass `--skip-auditwheel` if want to proceed anyway")]
42+
UndefinedPolicy(String),
4043
}
4144

4245
#[derive(Clone, Debug)]
@@ -281,7 +284,9 @@ pub fn auditwheel_rs(
281284
}
282285

283286
if let Some(platform_tag) = platform_tag {
284-
let mut policy = Policy::from_name(&platform_tag.to_string()).unwrap();
287+
let tag = platform_tag.to_string();
288+
let mut policy =
289+
Policy::from_name(&tag).ok_or_else(|| AuditWheelError::UndefinedPolicy(tag))?;
285290
policy.fixup_musl_libc_so_name(target.target_arch());
286291

287292
if let Some(highest_policy) = highest_policy {

tests/manylinux_incompliant.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Fail because we're running in manylinux2014, which can't build for manylinux 2010
4-
for PYBIN in /opt/python/cp3[6]*/bin; do
4+
for PYBIN in /opt/python/cp3[9]*/bin; do
55
if cargo run -- build --no-sdist -m test-crates/pyo3-mixed/Cargo.toml -i "${PYBIN}/python" --manylinux 2010 -o dist; then
66
echo "maturin build unexpectedly succeeded"
77
exit 1
@@ -12,11 +12,21 @@ done
1212

1313
# Fail because we're linking zlib with black-listed symbols(gzflags), which is not allowed in manylinux
1414
yum install -y zlib-devel
15-
for PYBIN in /opt/python/cp3[6]*/bin; do
15+
for PYBIN in /opt/python/cp3[9]*/bin; do
1616
if cargo run -- build --no-sdist -m test-crates/lib_with_disallowed_lib/Cargo.toml -i "${PYBIN}/python" --manylinux 2014 -o dist; then
1717
echo "maturin build unexpectedly succeeded"
1818
exit 1
1919
else
2020
echo "maturin build failed as expected"
2121
fi
2222
done
23+
24+
# Fail because manylinux_2_99 policy is not defined by auditwheel
25+
for PYBIN in /opt/python/cp3[9]*/bin; do
26+
if cargo run -- build --no-sdist -m test-crates/pyo3-mixed/Cargo.toml -i "${PYBIN}/python" --compatibility manylinux_2_99 -o dist; then
27+
echo "maturin build unexpectedly succeeded"
28+
exit 1
29+
else
30+
echo "maturin build failed as expected"
31+
fi
32+
done

0 commit comments

Comments
 (0)