Skip to content

Fix undefined auditwheel policy panic #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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