Skip to content
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

Cross compiling "python embedded in rust" binary (pyo3) for armv7 #41

Closed
124C41p opened this issue Apr 15, 2023 · 2 comments
Closed

Cross compiling "python embedded in rust" binary (pyo3) for armv7 #41

124C41p opened this issue Apr 15, 2023 · 2 comments

Comments

@124C41p
Copy link

124C41p commented Apr 15, 2023

Can your docker images (manylinux2014-cross or manylinux_2_28-cross) be used to cross compile a rust project for an armv7 machine which is using pyo3 to call python? If possible, I would prefer a static embedding of python into the binary.

Here is what I have tried so far:

  1. Create a docker image based on manylinux2014-cross with rust toolchain installed
FROM messense/manylinux2014-cross:armv7
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN /root/.cargo/bin/rustup target add armv7-unknown-linux-gnueabihf
  1. Create a tiny rust project inside the corresponding docker container

Cargo.toml:

[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[dependencies]
pyo3 = { version = "0.18.3", features = ["auto-initialize"] }

main.rs:

use pyo3::prelude::*;

fn main() -> PyResult<()> {
    Python::with_gil(|py| {
        let builtins = PyModule::import(py, "builtins")?;
        let total: i32 = builtins
            .getattr("sum")?
            .call1((vec![1, 2, 3],))?
            .extract()?;
        println!("{total}");
        Ok(())
    })
}
  1. Build with PYO3_CROSS_PYTHON_VERSION=3.11 cargo build

The build fails due to a linker error: ld: cannot find -lpython3.11. It seems to me there is a python installation missing for the target system. Is there an easy way to fix that issue?

@messense
Copy link
Member

@messense messense closed this as not planned Won't fix, can't repro, duplicate, stale Jun 18, 2023
@messense
Copy link
Member

If possible, I would prefer a static embedding of python into the binary

See PyO3/pyo3#416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants