diff options
| author | Tim Orling <tim.orling@konsulko.com> | 2022-03-12 12:49:24 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-16 08:48:08 +0000 |
| commit | 09ba720ec9a24990c61f94371485391c9924aaed (patch) | |
| tree | bb8dde39832cf91dc224b2976ac5623015612697 /meta/classes/pyo3.bbclass | |
| parent | 096086d0c8e0913176422a527742ab7e88709f35 (diff) | |
| download | poky-09ba720ec9a24990c61f94371485391c9924aaed.tar.gz | |
pyo3.bbclass: move from meta-python
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.
(From OE-Core rev: f3130197ed93fd60b4cad326940b02a5554ed089)
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/pyo3.bbclass')
| -rw-r--r-- | meta/classes/pyo3.bbclass | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/meta/classes/pyo3.bbclass b/meta/classes/pyo3.bbclass new file mode 100644 index 0000000000..6ce21329c2 --- /dev/null +++ b/meta/classes/pyo3.bbclass | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | # | ||
| 2 | # This class helps make sure that Python extensions built with PyO3 | ||
| 3 | # and setuptools_rust properly set up the environment for cross compilation | ||
| 4 | # | ||
| 5 | |||
| 6 | inherit cargo python3-dir siteinfo | ||
| 7 | |||
| 8 | export PYO3_CROSS="1" | ||
| 9 | export PYO3_CROSS_PYTHON_VERSION="${PYTHON_BASEVERSION}" | ||
| 10 | export PYO3_CROSS_LIB_DIR="${STAGING_LIBDIR}" | ||
| 11 | export CARGO_BUILD_TARGET="${HOST_SYS}" | ||
| 12 | export RUSTFLAGS | ||
| 13 | export PYO3_PYTHON="${PYTHON}" | ||
| 14 | export PYO3_CONFIG_FILE="${WORKDIR}/pyo3.config" | ||
| 15 | |||
| 16 | pyo3_do_configure () { | ||
| 17 | cat > ${WORKDIR}/pyo3.config << EOF | ||
| 18 | implementation=CPython | ||
| 19 | version=${PYTHON_BASEVERSION} | ||
| 20 | shared=true | ||
| 21 | abi3=false | ||
| 22 | lib_name=${PYTHON_DIR} | ||
| 23 | lib_dir=${STAGING_LIBDIR} | ||
| 24 | pointer_width=${SITEINFO_BITS} | ||
| 25 | build_flags=WITH_THREAD | ||
| 26 | suppress_build_script_link_lines=false | ||
| 27 | EOF | ||
| 28 | } | ||
| 29 | |||
| 30 | EXPORT_FUNCTIONS do_configure | ||
