summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch
diff options
context:
space:
mode:
authorGyorgy Sarvari <skandigraun@gmail.com>2025-03-10 14:31:17 +0100
committerKhem Raj <raj.khem@gmail.com>2025-03-10 09:41:56 -0700
commitb66b1eb9f68407a2545a35788ca642f18e5c9aea (patch)
tree5963bb91960bc662ebaa29bda66b36ffd3ddbc21 /meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch
parent72a041e46c124377300663654c7c255e7ce54239 (diff)
downloadmeta-openembedded-b66b1eb9f68407a2545a35788ca642f18e5c9aea.tar.gz
python3-pandas: compile against target version of numpy
python3-numpy headers are required by pandas to compile successfully. By default, this recipe used python3-numpy-native for compilation, which usually works. However in case the bitness of the build-host differs from the target, then problems arise. For example when compiling for 32-bit ARM on a x86-64 machine, the following error appears when trying to import the module: ValueError: Buffer dtype mismatch, expected 'const int64_t' but got 'long long' When running a diff on all numpy headers across native and target, only one header differs, _numpyconfig.h, in a significant way. This header defines the sizes of different datatypes used by numpy, and these sizes strongly depend on the arch bitness. This change switches from python3-numpy-native dependency to python3-numpy to ensure that the correct headers are used. Beside this also patch the meson script, so it accepts an option (numpy_inc_dir) to specify the location of these headers, since it is not able to query them from the class-target module The PYTHONPATH variable is extended with the target's RECIPE_SYSROOT, because numpy is specified as a dependency in meson, and it needs to find the module to continue successfully. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch b/meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch
new file mode 100644
index 0000000000..87023a24ec
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch
@@ -0,0 +1,66 @@
1From 16dd09e6c79768a24f5a50ec5985e0b6fdf17f35 Mon Sep 17 00:00:00 2001
2From: Gyorgy Sarvari <skandigraun@gmail.com>
3Date: Mon, 10 Mar 2025 13:52:11 +0100
4Subject: [PATCH] BLD: add option to specify numpy header location
5
6In some cases the numpy module might not be usable during build-time,
7especially when cross-compiling. (E.g. when compiling for arm32 on a
8x86-64 machine, the arm32 module is not usable at build time).
9
10This makes meson fail, as it isn't able to figure out the location of
11numpy headers.
12
13To allow an alternative way to find these headers, introduce a meson
14build option, where the location of the numpy headers can be specified.
15
16In case numpy module cannot be loaded for some reason to query the
17include folder location, fall back to the value of this meson option.
18
19Upstream-Status: Submitted [https://github.com/pandas-dev/pandas/pull/61095]
20
21Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
22---
23 meson.options | 1 +
24 pandas/meson.build | 13 ++++++++++---
25 2 files changed, 11 insertions(+), 3 deletions(-)
26 create mode 100644 meson.options
27
28diff --git a/meson.options b/meson.options
29new file mode 100644
30index 0000000000..3d3a18d145
31--- /dev/null
32+++ b/meson.options
33@@ -0,0 +1 @@
34+option('numpy_inc_dir', type : 'string', description : 'The absolute path to the numpy headers')
35diff --git a/pandas/meson.build b/pandas/meson.build
36index 435103a..a08c77a 100644
37--- a/pandas/meson.build
38+++ b/pandas/meson.build
39@@ -3,17 +3,24 @@ incdir_numpy = run_command(py,
40 '-c',
41 '''
42 import os
43-import numpy as np
44+
45+try:
46+ import numpy as np
47+ base_incdir = np.get_include()
48+except Exception:
49+ base_incdir = os.getenv('NUMPY_INC_DIR')
50+
51 try:
52 # Check if include directory is inside the pandas dir
53 # e.g. a venv created inside the pandas dir
54 # If so, convert it to a relative path
55- incdir = os.path.relpath(np.get_include())
56+ incdir = os.path.relpath(base_incdir)
57 except Exception:
58- incdir = np.get_include()
59+ incdir = base_incdir
60 print(incdir)
61 '''
62 ],
63+ env: {'NUMPY_INC_DIR': get_option('numpy_inc_dir')},
64 check: true
65 ).stdout().strip()
66