diff options
-rw-r--r-- | meta-python/recipes-devtools/python/python3-pandas/0001-BLD-add-option-to-specify-numpy-header-location.patch | 66 | ||||
-rw-r--r-- | meta-python/recipes-devtools/python/python3-pandas_2.2.2.bb | 9 |
2 files changed, 74 insertions, 1 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 @@ | |||
1 | From 16dd09e6c79768a24f5a50ec5985e0b6fdf17f35 Mon Sep 17 00:00:00 2001 | ||
2 | From: Gyorgy Sarvari <skandigraun@gmail.com> | ||
3 | Date: Mon, 10 Mar 2025 13:52:11 +0100 | ||
4 | Subject: [PATCH] BLD: add option to specify numpy header location | ||
5 | |||
6 | In some cases the numpy module might not be usable during build-time, | ||
7 | especially when cross-compiling. (E.g. when compiling for arm32 on a | ||
8 | x86-64 machine, the arm32 module is not usable at build time). | ||
9 | |||
10 | This makes meson fail, as it isn't able to figure out the location of | ||
11 | numpy headers. | ||
12 | |||
13 | To allow an alternative way to find these headers, introduce a meson | ||
14 | build option, where the location of the numpy headers can be specified. | ||
15 | |||
16 | In case numpy module cannot be loaded for some reason to query the | ||
17 | include folder location, fall back to the value of this meson option. | ||
18 | |||
19 | Upstream-Status: Submitted [https://github.com/pandas-dev/pandas/pull/61095] | ||
20 | |||
21 | Signed-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 | |||
28 | diff --git a/meson.options b/meson.options | ||
29 | new file mode 100644 | ||
30 | index 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') | ||
35 | diff --git a/pandas/meson.build b/pandas/meson.build | ||
36 | index 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 | |||
diff --git a/meta-python/recipes-devtools/python/python3-pandas_2.2.2.bb b/meta-python/recipes-devtools/python/python3-pandas_2.2.2.bb index c12a237653..ad9482e7dd 100644 --- a/meta-python/recipes-devtools/python/python3-pandas_2.2.2.bb +++ b/meta-python/recipes-devtools/python/python3-pandas_2.2.2.bb | |||
@@ -11,12 +11,14 @@ SRC_URI += " \ | |||
11 | file://0001-pyproject.toml-Downgrade-numpy-version-needs-to-1.x.patch \ | 11 | file://0001-pyproject.toml-Downgrade-numpy-version-needs-to-1.x.patch \ |
12 | " | 12 | " |
13 | 13 | ||
14 | SRC_URI:append:class-target = " file://0001-BLD-add-option-to-specify-numpy-header-location.patch " | ||
15 | |||
14 | SRC_URI[sha256sum] = "9e79019aba43cb4fda9e4d983f8e88ca0373adbb697ae9c6c43093218de28b54" | 16 | SRC_URI[sha256sum] = "9e79019aba43cb4fda9e4d983f8e88ca0373adbb697ae9c6c43093218de28b54" |
15 | 17 | ||
16 | inherit pkgconfig pypi python_mesonpy cython | 18 | inherit pkgconfig pypi python_mesonpy cython |
17 | 19 | ||
18 | DEPENDS += " \ | 20 | DEPENDS += " \ |
19 | python3-numpy-native \ | 21 | python3-numpy \ |
20 | python3-versioneer-native \ | 22 | python3-versioneer-native \ |
21 | " | 23 | " |
22 | 24 | ||
@@ -30,3 +32,8 @@ RDEPENDS:${PN} += " \ | |||
30 | python3-pytz \ | 32 | python3-pytz \ |
31 | python3-profile \ | 33 | python3-profile \ |
32 | " | 34 | " |
35 | |||
36 | PYTHONPATH:prepend:class-target = "${RECIPE_SYSROOT}${PYTHON_SITEPACKAGES_DIR}:" | ||
37 | export PYTHONPATH | ||
38 | |||
39 | EXTRA_OEMESON:append:class-target = " -Dnumpy_inc_dir=${RECIPE_SYSROOT}${PYTHON_SITEPACKAGES_DIR}/numpy/_core/include " | ||