diff --git a/Cargo.lock b/Cargo.lock index e1635b0f..f609181a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1751,6 +1751,7 @@ dependencies = [ "merry-llm", "pyo3", "pyo3-async-runtimes", + "pyo3-build-config", "schemars", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 02e75ce2..bddea23e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ jsonschema = { version = "0.30", default-features = false } image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp"] } libc = "0.2" pyo3 = { version = "0.29.0", features = ["extension-module"] } +pyo3-build-config = "0.29.0" pyo3-async-runtimes = { version = "0.29.0", features = ["tokio-runtime"] } pulldown-cmark = "0.13" ratatui = "0.30" diff --git a/crates/merry-py/Cargo.toml b/crates/merry-py/Cargo.toml index 323d7344..a0f0cc8f 100644 --- a/crates/merry-py/Cargo.toml +++ b/crates/merry-py/Cargo.toml @@ -26,5 +26,8 @@ serde_json.workspace = true tokio = { workspace = true, features = ["sync"] } tokio-util.workspace = true +[build-dependencies] +pyo3-build-config.workspace = true + [lints] workspace = true diff --git a/crates/merry-py/build.rs b/crates/merry-py/build.rs new file mode 100644 index 00000000..fd17ea6c --- /dev/null +++ b/crates/merry-py/build.rs @@ -0,0 +1,11 @@ +//! Emits the linker arguments the `_merry` extension module needs on macOS. +//! +//! Building as an extension module (`pyo3/extension-module`) stops PyO3 from +//! linking `libpython`, so the macOS linker must instead leave the Python +//! symbols to be resolved by the host interpreter when the module is loaded. +//! PyO3 only adds those arguments for projects that ask for them, and +//! `maturin` is not in the `cargo build` path, so the crate owns them here. + +fn main() { + pyo3_build_config::add_extension_module_link_args(); +}