Skip to content

Commit

Permalink
Merge pull request #740 from messense/fix-739
Browse files Browse the repository at this point in the history
Fix undefined auditwheel policy panic
  • Loading branch information
messense authored Dec 10, 2021
2 parents c04de80 + faff623 commit 18c40d1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 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
8 changes: 6 additions & 2 deletions src/auditwheel/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ pub enum AuditWheelError {
"Your library is not {0} compliant because it links the following forbidden libraries: {1:?}",
)]
PlatformTagValidationError(Policy, Vec<String>),
/// The elf file isn't manylinux/musllinux compaible. Contains unsupported architecture
/// The elf file isn't manylinux/musllinux compatible. 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,8 @@ 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(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 18c40d1

Please sign in to comment.