From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core@lists.openembedded.org
Cc: Tim Orling <tim.orling@konsulko.com>
Subject: [PATCH 03/33] pyo3.bbclass: move from meta-python
Date: Mon, 14 Mar 2022 22:48:07 +0000 [thread overview]
Message-ID: <20220314224837.834776-3-richard.purdie@linuxfoundation.org> (raw)
In-Reply-To: <20220314224837.834776-1-richard.purdie@linuxfoundation.org>
From: Tim Orling <tim.orling@konsulko.com>
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 <tim.orling@konsulko.com>
---
meta/classes/pyo3.bbclass | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 meta/classes/pyo3.bbclass
diff --git a/meta/classes/pyo3.bbclass b/meta/classes/pyo3.bbclass
new file mode 100644
index 00000000000..6ce21329c2e
--- /dev/null
+++ b/meta/classes/pyo3.bbclass
@@ -0,0 +1,30 @@
+#
+# 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"
+
+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
--
2.32.0
next prev parent reply other threads:[~2022-03-14 22:48 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 22:48 [PATCH 01/33] python3-setuptools-rust-native: from meta-python Richard Purdie
2022-03-14 22:48 ` [PATCH 02/33] python3-setuptools-rust-native: remove obsolete PIP_* Richard Purdie
2022-03-14 22:48 ` Richard Purdie [this message]
2022-03-14 22:48 ` [PATCH 04/33] setuptools3_rust.bbclass: move from meta-python Richard Purdie
2022-03-14 22:48 ` [PATCH 05/33] python3-cryptography: " Richard Purdie
2022-03-14 22:48 ` [PATCH 06/33] python3-pytest-subtests: " Richard Purdie
2022-03-14 22:48 ` [PATCH 07/33] python3-cryptography-vectors: " Richard Purdie
2022-03-14 22:48 ` [PATCH 08/33] python3-asn1crypto: move " Richard Purdie
2022-03-14 22:48 ` [PATCH 09/33] python3-cffi: " Richard Purdie
2022-03-14 22:48 ` [PATCH 10/33] python3-pytz: " Richard Purdie
2022-03-14 22:48 ` [PATCH 11/33] python3-bcrypt: " Richard Purdie
2022-03-14 22:48 ` [PATCH 12/33] python3-pretend: " Richard Purdie
2022-03-14 22:48 ` [PATCH 13/33] python3-psutil: " Richard Purdie
2022-03-14 22:48 ` [PATCH 14/33] poetry_core.bbclass: " Richard Purdie
2022-03-14 22:48 ` [PATCH 15/33] python3-poetry-core: " Richard Purdie
2022-03-14 22:48 ` [PATCH 16/33] python3-poetry-core: remove obsolete PIP_INSTALL_PACKAGE Richard Purdie
2022-03-14 22:48 ` [PATCH 17/33] python3-iso8601: move from meta-python Richard Purdie
2022-03-14 22:48 ` [PATCH 18/33] python3-typing-extensions: " Richard Purdie
2022-03-14 22:48 ` [PATCH 19/33] python3-semantic-version: " Richard Purdie
2022-03-14 22:48 ` [PATCH 20/33] python3-pycparser: " Richard Purdie
2022-03-14 22:48 ` [PATCH 21/33] python3-ply: " Richard Purdie
2026-01-30 1:12 ` [OE-core] " Randy MacLeod
2022-03-14 22:48 ` [PATCH 22/33] maintainers.inc: add python3-crypto and friends Richard Purdie
2022-03-14 22:48 ` [PATCH 23/33] py3o: Rename to python_py3o Richard Purdie
2022-03-14 22:48 ` [PATCH 24/33] setuptools3_rust: Rename to python_setuptools3_rust Richard Purdie
2022-03-14 22:48 ` [PATCH 25/33] poetry_core: Rename to python_poetry_core Richard Purdie
2022-03-14 22:48 ` [PATCH 26/33] poetry_core: update for renamed class pip_install_wheel to python_pep517 Richard Purdie
2022-03-14 22:48 ` [PATCH 27/33] ptest-packagelists.inc: add python3-cryptography Richard Purdie
2022-03-14 22:48 ` [PATCH 28/33] ptest-packagelists: add python3-bcrypt and -pytz Richard Purdie
2022-03-14 22:48 ` [PATCH 29/33] python3-cryptography: mark test_create_certificate_with_extensions as expected to fail Richard Purdie
2022-03-14 22:48 ` [PATCH 30/33] python3-psutil/python3-bcrypt: Add missing HOMEPAGE Richard Purdie
2022-03-14 22:48 ` [PATCH 31/33] python3-cryptography: Add missing ptest tomli dependency Richard Purdie
2022-03-14 22:48 ` [PATCH 32/33] python3-cryptography: remove obsolete PIP_INSTALL_DIST_PATH Richard Purdie
2022-03-14 22:48 ` [PATCH 33/33] python3-cryptography-vectors: Fix reproducibility Richard Purdie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220314224837.834776-3-richard.purdie@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
--cc=tim.orling@konsulko.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox