meta-openembedded/meta-python/recipes-devtools/python/python3-pandas_2.2.2.bb
Gyorgy Sarvari b66b1eb9f6
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>
2025-03-10 09:41:56 -07:00

40 lines
1.3 KiB
Clojure

SUMMARY = "pandas library for high-performance data analysis tools"
DESCRIPTION = "pandas is an open source, BSD-licensed library providing \
high-performance, easy-to-use data structures and data analysis tools for \
the Python programming language."
HOMEPAGE = "http://pandas.pydata.org/"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=cb819092901ddb13a7d0a4f5e05f098a"
SRC_URI += " \
file://0001-pyproject.toml-don-t-pin-dependency-versions.patch \
file://0001-pyproject.toml-Downgrade-numpy-version-needs-to-1.x.patch \
"
SRC_URI:append:class-target = " file://0001-BLD-add-option-to-specify-numpy-header-location.patch "
SRC_URI[sha256sum] = "9e79019aba43cb4fda9e4d983f8e88ca0373adbb697ae9c6c43093218de28b54"
inherit pkgconfig pypi python_mesonpy cython
DEPENDS += " \
python3-numpy \
python3-versioneer-native \
"
CFLAGS:append:toolchain-clang = " -Wno-error=deprecated-declarations"
RDEPENDS:${PN} += " \
python3-json \
python3-numpy \
python3-dateutil \
python3-dateutil-zoneinfo \
python3-pytz \
python3-profile \
"
PYTHONPATH:prepend:class-target = "${RECIPE_SYSROOT}${PYTHON_SITEPACKAGES_DIR}:"
export PYTHONPATH
EXTRA_OEMESON:append:class-target = " -Dnumpy_inc_dir=${RECIPE_SYSROOT}${PYTHON_SITEPACKAGES_DIR}/numpy/_core/include "