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

Meta python merge #520

Closed
wants to merge 2 commits into from
Closed

Meta python merge #520

wants to merge 2 commits into from

Commits on Jan 18, 2022

  1. pyo3.bbclass: add class for PyO3 cross-compilation

    PyO3 provides Rust bindings for Python, including tools for creating native
    Python extension modules. Running and interacting with Python code from a
    Rust binary is also supported.
    
    This class sets up the cross-compilation environment.
    
    Export PYO3_CROSS, PYO3_CROSS_LIB_DIR, PYO3_CROSS_INCLUDE_DIR and CARGO_BUILD_TARGET
    to inform tools like setuptools-rust we are cross-compiling.
    
    Export RUSTFLAGS so cargo can find 'std' and 'core' for target
    
    Dynamically generate PyO3 config file and export PYO3_CONFIG_FILE
    absolute path. This is the trick that finally made pyo3 work.
    
    Signed-off-by: Tim Orling <[email protected]>
    Signed-off-by: Khem Raj <[email protected]>
    Signed-off-by: Trevor Gamblin <[email protected]>
    moto-timo authored and Trevor Gamblin committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    dfa18ca View commit details
    Browse the repository at this point in the history
  2. setuptools3_rust.bbclass: setuptoools Rust plugin

    setuptools-rust is a plugin for setuptools to build Rust Python extensions
    implemented with PyO3 or rust-cpython.
    
    Compile and distribute Python extensions written in Rust as easily as if
    they were written in C.
    
    This class inherits pyo3.bbclass (and therefore cargo.bbclass) and
    setuptools3.bbclass to make it easier to build Python modules with Rust
    extensions.
    
    Need to call pyo3_do_configure to properly setup the PyO3 environment
    for cross-compiling.
    
    Need to call cargo_common_do_configure to setup cargo_home/config so
    that the linker properly finds e.g. crti.o and crtbeginS.o
    
    It is strongly recommended to provide crates needed for your recipe
    using the crate:// fetcher. This can be helped with the cargo-bitbake
    command [1].
    
    If you choose not to use the crate fetcher, bitbake vendoring will not
    work with setuptools-rust, as it errors out immediately because it cannot
    find pyo3 or some other crate. The (strongly discouraged) workaround for
    this is to set:
    
    CARGO_DISABLE_BITBAKE_VENDORING = "1"
    
    [1] https://crates.io/crates/cargo-bitbake
    
    Signed-off-by: Tim Orling <[email protected]>
    Signed-off-by: Khem Raj <[email protected]>
    Signed-off-by: Trevor Gamblin <[email protected]>
    moto-timo authored and Trevor Gamblin committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    e9d2e8e View commit details
    Browse the repository at this point in the history