Open
Description
Hi! Awesome project.
I'm currently working on Python bindings for a Rust library. I occasionally have to call small Python snippets from the Rust code. This library would be a very elegant solution to that.
However, when I try to compile inline-python
with the feature "extension-module"
in PyO3 enabled I get an error:
error: /home/bminixhofer/Documents/string_sum/target/debug/deps/libinline_python_macros-2b68321f767fc207.so: undefined symbol: PyTuple_SetItem
--> /home/bminixhofer/.cargo/registry/src/github.com-1ecc6299db9ec823/inline-python-0.5.1/src/lib.rs:143:9
|
143 | pub use inline_python_macros::python;
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: could not compile `inline-python`.
Caused by:
process didn't exit successfully: `rustc --crate-name inline_python --edition=2018 /home/bminixhofer/.cargo/registry/src/github.com-1ecc6299db9ec823/inline-python-0.5.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cbitcode-in-rlib=no -C debuginfo=2 -C metadata=6055137a725d9ef2 -C extra-filename=-6055137a725d9ef2 --out-dir /home/bminixhofer/Documents/string_sum/target/debug/deps -L dependency=/home/bminixhofer/Documents/string_sum/target/debug/deps --extern inline_python_macros=/home/bminixhofer/Documents/string_sum/target/debug/deps/libinline_python_macros-2b68321f767fc207.so --extern pyo3=/home/bminixhofer/Documents/string_sum/target/debug/deps/libpyo3-df6fd04a55a3c6e8.rmeta --cap-lints allow` (exit code: 1)
To reproduce
Cargo.toml
[package]
name = "string-sum"
version = "0.1.0"
edition = "2018"
authors = [""]
[lib]
name = "string_sum"
crate-type = ["cdylib"]
[dependencies]
inline-python = "0.5.1"
[dependencies.pyo3]
version = "0.9.0"
features = ["extension-module"]
src/lib.rs
#![feature(proc_macro_hygiene)]
use inline_python::python;
use inline_python::pyo3::prelude::*;
use inline_python::pyo3::wrap_pyfunction;
#[pyfunction]
/// Formats the sum of two numbers as string.
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
python! {
print("Hello!")
}
Ok((a + b).to_string())
}
#[pymodule]
/// A Python module implemented in Rust.
fn string_sum(py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(sum_as_string))?;
Ok(())
}
Rust version: rustc 1.45.0-nightly (fa51f810e 2020-04-29)
Thanks for any help!
Metadata
Metadata
Assignees
Labels
No labels