From: Rob Woolley <rob.woolley@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Cc: Rob Woolley <rob.woolley@windriver.com>, <alex.kanavin@gmail.com>
Subject: [PATCH v2 2/3] boost-build-native: Add python-numpy-include feature
Date: Wed, 12 Aug 2026 13:34:32 -0700 [thread overview]
Message-ID: <20260812-fix-boost-v2-2-cbcb65f5e186@windriver.com> (raw)
In-Reply-To: <20260812-fix-boost-v2-0-cbcb65f5e186@windriver.com>
The Boost python.jam file attempts to import the NumPy module to determine
whether the Boost.Python NumPy extension should be enabled. This approach
is problematic when cross-compiling, particularly when NumPy includes
native extensions built for the target architecture.
Introduce the new python-numpy-include feature to avoid probing for NumPy
at build time by allowing the include path to be specified explicitly.
This enables BitBake to provide the correct NumPy include directory from
the recipe sysroot, eliminating the need to import the target NumPy
module from site-packages.
Signed-off-by: Rob Woolley <rob.woolley@windriver.com>
---
.../boost/boost-build-native_1.91.0.bb | 3 +-
.../add-python-numpy-include-feature.patch | 74 ++++++++++++++++++++++
2 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-support/boost/boost-build-native_1.91.0.bb b/meta/recipes-support/boost/boost-build-native_1.91.0.bb
index c276cf436d..5babd02448 100644
--- a/meta/recipes-support/boost/boost-build-native_1.91.0.bb
+++ b/meta/recipes-support/boost/boost-build-native_1.91.0.bb
@@ -6,7 +6,8 @@ SECTION = "devel"
LICENSE = "BSL-1.0"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e4224ccaecb14d942c71d31bef20d78c"
-SRC_URI = "git://github.com/boostorg/build;protocol=https;branch=master;tag=boost-${PV}"
+SRC_URI = "git://github.com/boostorg/build;protocol=https;branch=master;tag=boost-${PV} \
+ file://add-python-numpy-include-feature.patch"
SRCREV = "85252c9d6a3817daca23ddae94ce16c7be4d2c12"
PE = "1"
diff --git a/meta/recipes-support/boost/boost-build/add-python-numpy-include-feature.patch b/meta/recipes-support/boost/boost-build/add-python-numpy-include-feature.patch
new file mode 100644
index 0000000000..708a5a43f7
--- /dev/null
+++ b/meta/recipes-support/boost/boost-build/add-python-numpy-include-feature.patch
@@ -0,0 +1,74 @@
+Add python-numpy-include feature
+
+The Boost python.jam file attempts to import the NumPy module to determine
+whether the Boost.Python NumPy extension should be enabled. This approach
+is problematic when cross-compiling, particularly when NumPy includes
+native extensions built for the target architecture.
+
+Introduce the new python-numpy-include feature to avoid probing for NumPy
+at build time by allowing the include path to be specified explicitly.
+
+This enables BitBake to provide the correct NumPy include directory from
+the recipe sysroot, eliminating the need to import the target NumPy
+module from site-packages.
+
+Upstream-Status: Pending
+
+Signed-off-by: Rob Woolley <rob.woolley@windriver.com>
+
+--- a/src/tools/python.jam
++++ b/src/tools/python.jam
+@@ -65,6 +65,9 @@
+ # installed in the development system's default paths.
+ feature.feature pythonpath : : free optional path ;
+
++# Declare python-numpy-include as a free feature accepting a path
++feature.feature python-numpy-include : : free path ;
++
+ # The best configured version of Python 2 and 3.
+ py2-version = ;
+ py3-version = ;
+@@ -866,21 +869,33 @@
+ # Discover the presence of NumPy
+ #
+ debug-message "Checking for NumPy..." ;
+- local full-cmd = "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())" ;
+- local full-cmd = $(interpreter-cmd)" -c \"$(full-cmd)\"" ;
+- debug-message "running command '$(full-cmd)'" ;
+- local result = [ SHELL $(full-cmd) : strip-eol : exit-status ] ;
+- if $(result[2]) = 0
+- {
++
++ local custom-numpy = [ feature.get-values <python-numpy-include> : $(condition) ] ;
++
++ if $(custom-numpy)
++ {
+ .numpy = true ;
+- .numpy-include = $(result[1]) ;
++ .numpy-include = $(custom-numpy) ;
+ debug-message "NumPy enabled" ;
+ }
+ else
+ {
+- debug-message "NumPy disabled. Reason:" ;
+- debug-message " $(full-cmd) aborted with " ;
+- debug-message " $(result[1])" ;
++ local full-cmd = "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())" ;
++ local full-cmd = $(interpreter-cmd)" -c \"$(full-cmd)\"" ;
++ debug-message "running command '$(full-cmd)'" ;
++ local result = [ SHELL $(full-cmd) : strip-eol : exit-status ] ;
++ if $(result[2]) = 0
++ {
++ .numpy = true ;
++ .numpy-include = $(result[1]) ;
++ debug-message "NumPy enabled" ;
++ }
++ else
++ {
++ debug-message "NumPy disabled. Reason:" ;
++ debug-message " $(full-cmd) aborted with " ;
++ debug-message " $(result[1])" ;
++ }
+ }
+
+ #
--
2.49.0
next prev parent reply other threads:[~2026-08-12 20:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 20:34 [PATCH v2 0/3] boost: Add Boost.Python NumPy Rob Woolley
2026-08-12 20:34 ` [PATCH v2 1/3] boost: Use python3-native executable Rob Woolley
2026-08-12 20:46 ` Patchtest results for " patchtest
2026-08-12 20:34 ` Rob Woolley [this message]
2026-08-12 20:34 ` [PATCH v2 3/3] boost: Add support for Boost.Python NumPy extension Rob Woolley
2026-08-12 20:46 ` Patchtest results for " patchtest
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=20260812-fix-boost-v2-2-cbcb65f5e186@windriver.com \
--to=rob.woolley@windriver.com \
--cc=alex.kanavin@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.