clojure-lsp: update to 2024.08.05.
[void-pkg.git] / common / build-helper / numpy.sh
blob0adce85e151fdec191a4cdb79fc6f25b5c9be080
2 # numpy - build-helper for packages that compile against python3-numpy
4 # This build-helper makes sure packages can find python3-numpy libraries and
5 # headers on the target architecture rather than the host, as well as making
6 # sure the gfortran cross compiler is properly identified.
8 # Even for cross compilation, numpy should be available on the host to ensure
9 # that the host interpreter doesn't complain about missing deps
10 if [[ $hostmakedepends != *"python3-numpy"* ]]; then
11 hostmakedepends+=" python3-numpy"
14 [ -z "$CROSS_BUILD" ] && return 0
16 if [[ $makedepends != *"python3-numpy"* ]]; then
17 makedepends+=" python3-numpy"
20 # python3-setuptools finds numpy libs and headers on the host first;
21 # adding search paths up front allows the target to take priority
22 CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_sitelib}/numpy/_core/include"
23 LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_sitelib}/numpy/_core/lib"
24 LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_sitelib}/numpy/random/lib"
26 # distutils from python3-numpy looks to environment variables F77 and
27 # F90 rather than the XBPS-set FC
28 export F77="${FC}"
29 export F90="${FC}"
31 # When compiling and linking FORTRAN, distutils from python3-numpy
32 # refuses respect any linker name except "gfortran"; symlink to the
33 # cross-compiler to that the right linker and compiler will be used
34 if _gfortran=$(command -v "${FC}"); then
35 ln -sf "${_gfortran}" "${XBPS_WRAPPERDIR}/gfortran"
37 unset _gfortran
39 # Write a secondary meson cross file for numpy configuration
40 if [[ "${build_helper}" = *meson* ]]; then
41 _npy_meson_cross="${XBPS_WRAPPERDIR}/meson/xbps_numpy.cross"
42 _cross_py_site="${XBPS_CROSS_BASE}/${py3_sitelib}"
44 if [ ! -e "${_npy_meson_cross}" ] || [ -n "$XBPS_BUILD_FORCEMODE" ]; then
45 mkdir -p "${XBPS_WRAPPERDIR}/meson"
46 cat > "${_npy_meson_cross}" <<-EOF
47 [properties]
48 numpy-include-dir = '${_cross_py_site}/numpy/_core/include'
49 pythran-include-dir = '${_cross_py_site}/pythran'
50 EOF
52 unset _npy_meson_cross _cross_py_site