@@ -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"
new file mode 100644
@@ -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])" ;
++ }
+ }
+
+ #
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(-)