From fd231746a4a9b6ab6cf1eeda2fd22773d73af742 Mon Sep 17 00:00:00 2001 From: messense Date: Sat, 22 Oct 2022 23:38:17 +0800 Subject: [PATCH] Fix macOS `LC_ID_DYLIB` for abi3 wheels --- Changelog.md | 1 + src/compile.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 445eb59b4..e728857f8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add `--src` option to generate src layout for mixed Python/Rust projects in [#1189](https://github.com/PyO3/maturin/pull/1189) * Add Python metadata support for `license-file` field of `Cargo.toml` in [#1195](https://github.com/PyO3/maturin/pull/1195) * Upgrade to clap 4.0 in [#1197](https://github.com/PyO3/maturin/pull/1197). This bumps MSRV to 1.61.0. +* Fix macOS `LC_ID_DYLIB` for abi3 wheels in [#1208](https://github.com/PyO3/maturin/pull/1208) ## [0.13.6] - 2022-10-08 diff --git a/src/compile.rs b/src/compile.rs index 3b7d64ebc..deadf505c 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -213,21 +213,19 @@ fn compile_target( } } - let module_name = &context.module_name; - let so_filename = match python_interpreter { - Some(python_interpreter) => python_interpreter.get_library_name(module_name), - // abi3 - None => { - format!("{base}.abi3.so", base = module_name) - } - }; - // https://github.com/PyO3/pyo3/issues/88#issuecomment-337744403 if target.is_macos() { if let BridgeModel::Bindings(..) | BridgeModel::BindingsAbi3(..) = bindings_crate { // Change LC_ID_DYLIB to the final .so name for macOS targets to avoid linking with // non-existent library. // See https://github.com/PyO3/setuptools-rust/issues/106 for detail + let module_name = &context.module_name; + let so_filename = match bindings_crate { + BridgeModel::BindingsAbi3(..) => format!("{base}.abi3.so", base = module_name), + _ => python_interpreter + .expect("missing python interpreter for non-abi3 wheel build") + .get_library_name(module_name), + }; let macos_dylib_install_name = format!("link-args=-Wl,-install_name,@rpath/{}", so_filename); let mac_args = [