Skip to content

Commit

Permalink
Fix undefined auditwheel policy panic
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 10, 2021
1 parent c04de80 commit 68783fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[codespell]
ignore-words-list = crate
skip = ./.git,./target,./test-crates/venvs,./guide/book
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

## [0.12.4] - 2021-12-06

Expand Down
7 changes: 6 additions & 1 deletion src/auditwheel/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub enum AuditWheelError {
/// The elf file isn't manylinux/musllinux compaible. Contains unsupported architecture
#[error("Your library is not {0} compliant because it has unsupported architecture: {1}")]
UnsupportedArchitecture(Policy, String),
/// This platform tag isn't defined by auditwheel yet
#[error("{0} compatibility policy is not defined by auditwheel yet, pass `--skip-auditwheel` to proceed anyway")]
UndefinedPolicy(String),
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -281,7 +284,9 @@ pub fn auditwheel_rs(
}

if let Some(platform_tag) = platform_tag {
let mut policy = Policy::from_name(&platform_tag.to_string()).unwrap();
let tag = platform_tag.to_string();
let mut policy =
Policy::from_name(&tag).ok_or_else(|| AuditWheelError::UndefinedPolicy(tag))?;
policy.fixup_musl_libc_so_name(target.target_arch());

if let Some(highest_policy) = highest_policy {
Expand Down
14 changes: 12 additions & 2 deletions tests/manylinux_incompliant.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

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

# Fail because we're linking zlib with black-listed symbols(gzflags), which is not allowed in manylinux
yum install -y zlib-devel
for PYBIN in /opt/python/cp3[6]*/bin; do
for PYBIN in /opt/python/cp3[9]*/bin; do
if cargo run -- build --no-sdist -m test-crates/lib_with_disallowed_lib/Cargo.toml -i "${PYBIN}/python" --manylinux 2014 -o dist; then
echo "maturin build unexpectedly succeeded"
exit 1
else
echo "maturin build failed as expected"
fi
done

# Fail because manylinux_2_99 policy is not defined by auditwheel
for PYBIN in /opt/python/cp3[9]*/bin; do
if cargo run -- build --no-sdist -m test-crates/pyo3-mixed/Cargo.toml -i "${PYBIN}/python" --compatibility manylinux_2_99 -o dist; then
echo "maturin build unexpectedly succeeded"
exit 1
else
echo "maturin build failed as expected"
fi
done

0 comments on commit 68783fc

Please sign in to comment.