From 7cf147c7cdd15c8bf5691e8d2a5d909a58e7022f Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Thu, 21 Sep 2023 11:00:56 -0400 Subject: [PATCH 1/4] common/build-helper/numpy.sh: write meson cross file when needed --- Manual.md | 5 +++++ common/build-helper/numpy.sh | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/Manual.md b/Manual.md index 88f9f5243258a..27f27394a7129 100644 --- a/Manual.md +++ b/Manual.md @@ -1084,6 +1084,11 @@ meson for cross builds. This is particularly useful for building packages that w invocations (e.g., `python3-pep517` packages that use a meson backend) and is added by default for packages that use the `meson` build style. +- `numpy` configures the environment for cross-compilation of python packages that provide +compiled extensions linking to NumPy C libraries. If the `meson` build helper is also +configured, a secondary cross file, `${XBPS_WRAPPERDIR}/meson/xbps_numpy.cross`, will be +written to inform meson where common NumPy components may be found. + - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow executing cross-compiled binaries inside qemu. It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson diff --git a/common/build-helper/numpy.sh b/common/build-helper/numpy.sh index 74c6421165293..bf40390ad1cae 100644 --- a/common/build-helper/numpy.sh +++ b/common/build-helper/numpy.sh @@ -34,4 +34,14 @@ if [ "$CROSS_BUILD" ]; then ln -sf "${_gfortran}" "${XBPS_WRAPPERDIR}/gfortran" fi unset _gfortran + + # Write a secondary meson cross file for numpy configuration + if [[ "${build_helper}" = *meson* ]]; then + mkdir -p "${XBPS_WRAPPERDIR}/meson" + cat > "${XBPS_WRAPPERDIR}/meson/xbps_numpy.cross" <<-EOF + [properties] + numpy-include-dir = '${XBPS_CROSS_BASE}/${py3_sitelib}/numpy/core/include' + pythran-include-dir = '${XBPS_CROSS_BASE}/${py3_sitelib}/pythran' + EOF + fi fi From 74428db545a5564aec779b373af730c48c53bdd7 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Thu, 21 Sep 2023 11:01:24 -0400 Subject: [PATCH 2/4] common/build-style/python3-pep517.sh: use meson cross files by default --- common/build-style/python3-pep517.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh index 2d5ff7caf34eb..5ec20dd117f8a 100644 --- a/common/build-style/python3-pep517.sh +++ b/common/build-style/python3-pep517.sh @@ -4,8 +4,18 @@ do_build() { : ${make_build_target:=.} - : ${make_build_args:=--no-isolation --wheel} - python3 -m build ${make_build_args} ${make_build_target} + + if [ "${CROSS_BUILD}" ] && [[ "${build_helper}" = *meson* ]]; then + local mcross="-Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson" + make_build_args+=" ${mcross}/xbps_meson.cross" + + if [[ "${build_helper}" = *numpy* ]]; then + make_build_args+=" ${mcross}/xbps_numpy.cross" + fi + fi + + python3 -m build --no-isolation --wheel \ + ${make_build_args} ${make_build_target} } do_check() { From 881738d6d9ab0c68560182cf5fd5ee35ce295e36 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Thu, 21 Sep 2023 11:19:38 -0400 Subject: [PATCH 3/4] python3-scipy: use meson-aware numpy helper and pep517 style --- srcpkgs/python3-scipy/template | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/srcpkgs/python3-scipy/template b/srcpkgs/python3-scipy/template index e99919babf3bf..738da68ac0bc8 100644 --- a/srcpkgs/python3-scipy/template +++ b/srcpkgs/python3-scipy/template @@ -3,9 +3,10 @@ pkgname=python3-scipy version=1.11.2 revision=1 build_style=python3-pep517 -build_helper="meson" -make_build_args="--no-isolation --wheel - $(vopt_if openblas "" "-Csetup-args=-Dblas=blas -Csetup-args=-Dlapack=lapack")" +build_helper="meson numpy" +make_build_args=" + $(vopt_if openblas "" "-Csetup-args=-Dblas=blas -Csetup-args=-Dlapack=lapack") +" hostmakedepends="python3-build python3-installer python3-meson-python python3-wheel python3-Cython python3-pybind11 pythran python3-numpy gcc-fortran pkg-config" @@ -23,11 +24,6 @@ make_check="no" # Tests need an installed copy to run and meson makes this tough build_options="openblas" if [ "$CROSS_BUILD" ]; then - make_build_args+=" - -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/xbps_meson.cross - -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/python.cross - " - _pybind11_dir="${py3_sitelib}/pybind11" export PKG_CONFIG_PATH="${XBPS_CROSS_BASE}/${_pybind11_dir}/share/pkgconfig" # pybind11 uses a path relative to the pkgconfig file to set $prefix, @@ -51,17 +47,6 @@ if [ "$build_option_openblas" ]; then esac fi -post_patch() { - if [ "$CROSS_BUILD" ]; then - local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}" - cat > "${XBPS_WRAPPERDIR}/meson/python.cross" <<-EOF - [properties] - numpy-include-dir = '${_xpy}/numpy/core/include' - pythran-include-dir = '${_xpy}/pythran' - EOF - fi -} - pre_build() { if [ "$CROSS_BUILD" ]; then # Meson can't tolerate $CC with arguments as set by the build helper From 9bfb2b4f8defbba0d3266cba0fb782d124c1d0c4 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Thu, 21 Sep 2023 11:29:51 -0400 Subject: [PATCH 4/4] python3-scikit-image: use meson-aware numpy helper and pep517 style --- srcpkgs/python3-scikit-image/template | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/srcpkgs/python3-scikit-image/template b/srcpkgs/python3-scikit-image/template index b19743e50f37d..3fa9e9231e6cc 100644 --- a/srcpkgs/python3-scikit-image/template +++ b/srcpkgs/python3-scikit-image/template @@ -3,7 +3,7 @@ pkgname=python3-scikit-image version=0.21.0 revision=1 build_style=python3-pep517 -build_helper="meson" +build_helper="meson numpy" hostmakedepends="python3-build python3-installer python3-meson-python python3-wheel python3-setuptools python3-packaging python3-Cython pythran python3-lazy_loader python3-numpy pkg-config" @@ -20,23 +20,6 @@ checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652 # Tests require data files and unpackaged dependencies make_check=no -if [ "${CROSS_BUILD}" ]; then - make_build_args+=" --no-isolation --wheel - -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/xbps_meson.cross - -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/python.cross" -fi - -post_patch() { - if [ "${CROSS_BUILD}" ]; then - local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}" - cat > "${XBPS_WRAPPERDIR}/meson/python.cross" <<-EOF - [properties] - numpy-include-dir = '${_xpy}/numpy/core/include' - pythran-include-dir = '${_xpy}/pythran' - EOF - fi -} - pre_build() { if [ "${CROSS_BUILD}" ]; then # Meson can't tolerate $CC with arguments as set by build helper