kumquat-buildroot/package/python-numpy/python-numpy.mk
Graeme Smecher f6c33f3e89 host-python-numpy: correct implied host-lapack/host-blas dependency.
Before commit ca63464e37 (package/python-numpy: bump to version
1.25.0), numpy was using python distuils. Then, the default for BLAS and
LAPACK detection was to disable support if they were not found, even
when OPENBLAS is installed on the host system.

Commit ca63464e37 switched python-numpy to use the meson-package
infrastructure, where the default has changed, and now fails when the
host system does have OPENBLAS installed:

    buildroot$ make
    >>> host-python-numpy 1.25.0 Configuring
    [...]
    Run-time dependency openblas found: NO (tried pkgconfig and cmake)
    WARNING: CMake Toolchain: Failed to determine CMake compilers state
    Run-time dependency openblas found: YES 0.3.21
    Dependency openblas found: YES 0.3.21 (cached)
    Program _build_utils/process_src_template.py found: YES (/path/to/buildroot/output/host/bin/python3 /path/to/buildroot/output/build/host-python-numpy-1.25.0/numpy/_build_utils/process_src_template.py)
    Program _build_utils/tempita.py found: YES (/path/to/buildroot/output/build/host-python-numpy-1.25.0/numpy/_build_utils/tempita.py)

    output/build/host-python-numpy-1.25.0/numpy/meson.build:201:44: ERROR: Could not get cmake variable and no default provided for <CMakeDependency OpenBLAS: True None>
    [...]

Two obvious ways to correct this:

- Add some kind of host-lapack / host-openblas dependency to
  host-python-numpy, or
- Tell host-python-numpy not to look for (or rely on) external code.

Because the host numpy environment shouldn't be doing any numerical
heavy lifting, we opt for the latter here.

Signed-off-by: Graeme Smecher <gsmecher@threespeedlogic.com>
[yann.morin.1998@free.fr:
  - explain why the issue was not found before
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2024-02-05 19:00:12 +01:00

63 lines
2.2 KiB
Makefile

################################################################################
#
# python-numpy
#
################################################################################
PYTHON_NUMPY_VERSION = 1.25.0
PYTHON_NUMPY_SOURCE = numpy-$(PYTHON_NUMPY_VERSION).tar.gz
PYTHON_NUMPY_SITE = https://github.com/numpy/numpy/releases/download/v$(PYTHON_NUMPY_VERSION)
PYTHON_NUMPY_LICENSE = BSD-3-Clause, MIT, Zlib
PYTHON_NUMPY_LICENSE_FILES = \
LICENSE.txt \
numpy/core/src/multiarray/dragon4.c \
numpy/core/include/numpy/libdivide/LICENSE.txt \
numpy/linalg/lapack_lite/LICENSE.txt \
tools/npy_tempita/license.txt
PYTHON_NUMPY_CPE_ID_VENDOR = numpy
PYTHON_NUMPY_CPE_ID_PRODUCT = numpy
PYTHON_NUMPY_DEPENDENCIES = host-python-cython python3
HOST_PYTHON_NUMPY_DEPENDENCIES = host-python-cython
PYTHON_NUMPY_CONF_ENV += \
_PYTHON_SYSCONFIGDATA_NAME=$(PKG_PYTHON_SYSCONFIGDATA_NAME) \
PYTHONPATH=$(PYTHON3_PATH)
ifeq ($(BR2_PACKAGE_LAPACK),y)
PYTHON_NUMPY_DEPENDENCIES += lapack
PYTHON_NUMPY_CONF_OPTS += -Dlapack=lapack
else
PYTHON_NUMPY_CONF_OPTS += -Dlapack=""
endif
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
PYTHON_NUMPY_DEPENDENCIES += openblas
PYTHON_NUMPY_CONF_OPTS += -Dblas=openblas
else
PYTHON_NUMPY_CONF_OPTS += -Dblas=""
endif
# Rather than add a host-blas or host-lapack dependencies, just use unoptimized,
# in-tree code.
HOST_PYTHON_NUMPY_CONF_OPTS = -Dblas="" -Dlapack=""
# Fixup the npymath.ini prefix path with actual target staging area where
# numpy core was built. Without this, target builds using numpy distutils
# extensions like python-scipy, python-numba cannot find -lnpymath since
# it uses host libraries (like libnpymath.a).
# So, the numpy distutils extension packages would explicitly link this
# config path for their package environment.
define PYTHON_NUMPY_FIXUP_NPY_PKG_CONFIG_FILES
$(SED) '/^pkgdir=/d;/^prefix=/i pkgdir=$(PYTHON3_PATH)/site-packages/numpy/core' \
$(PYTHON3_PATH)/site-packages/numpy/core/lib/npy-pkg-config/npymath.ini
endef
PYTHON_NUMPY_POST_INSTALL_STAGING_HOOKS += PYTHON_NUMPY_FIXUP_NPY_PKG_CONFIG_FILES
# Some package may include few headers from NumPy, so let's install it
# in the staging area.
PYTHON_NUMPY_INSTALL_STAGING = YES
$(eval $(meson-package))
$(eval $(host-meson-package))