aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Orling <tim.orling@konsulko.com>2022-01-14 16:11:19 -0800
committerTim Orling <tim.orling@konsulko.com>2022-01-15 10:42:16 -0800
commit110a1da7ed82cc6780a8a387931e7eeb722b2cd5 (patch)
tree900b35fe3ae5cf750f3a7d432f40ee8e5ffc6f33
parentd8ed38996c92538bf44f7dfa2ce94b8496454243 (diff)
downloadmeta-openembedded-contrib-110a1da7ed82cc6780a8a387931e7eeb722b2cd5.tar.gz
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. Signed-off-by: Tim Orling <tim.orling@konsulko.com>
-rw-r--r--meta-python/classes/pyo3.bbclass31
1 files changed, 31 insertions, 0 deletions
diff --git a/meta-python/classes/pyo3.bbclass b/meta-python/classes/pyo3.bbclass
new file mode 100644
index 0000000000..f14afc987a
--- /dev/null
+++ b/meta-python/classes/pyo3.bbclass
@@ -0,0 +1,31 @@
+#
+# This class helps make sure that Python extensions built with PyO3
+# and setuptools_rust properly set up the environment for cross compilation
+#
+
+inherit cargo python3-dir siteinfo
+
+export PYO3_CROSS="1"
+export PYO3_CROSS_PYTHON_VERSION="${PYTHON_BASEVERSION}"
+export PYO3_CROSS_LIB_DIR="${STAGING_LIBDIR}"
+export CARGO_BUILD_TARGET="${HOST_SYS}"
+export RUSTFLAGS
+export PYO3_PYTHON="${PYTHON}"
+export PYO3_CONFIG_FILE="${WORKDIR}/pyo3.config"
+#export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__linux_${HOST_SYS}"
+
+pyo3_do_configure () {
+ cat > ${WORKDIR}/pyo3.config << EOF
+implementation=CPython
+version=${PYTHON_BASEVERSION}
+shared=true
+abi3=false
+lib_name=${PYTHON_DIR}
+lib_dir=${STAGING_LIBDIR}
+pointer_width=${SITEINFO_BITS}
+build_flags=WITH_THREAD
+suppress_build_script_link_lines=false
+EOF
+}
+
+EXPORT_FUNCTIONS do_configure