From e397870c0e8e04ab0a8f3914a51fc8f83adf240f Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Fri, 24 Feb 2023 09:41:50 -0500 Subject: [PATCH] python3-scipy: update to 1.11.0, build with meson --- .../python3-scipy/patches/numpy-version.patch | 14 ++++ srcpkgs/python3-scipy/template | 72 +++++++++++-------- 2 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 srcpkgs/python3-scipy/patches/numpy-version.patch diff --git a/srcpkgs/python3-scipy/patches/numpy-version.patch b/srcpkgs/python3-scipy/patches/numpy-version.patch new file mode 100644 index 00000000000..74f9b4a919b --- /dev/null +++ b/srcpkgs/python3-scipy/patches/numpy-version.patch @@ -0,0 +1,14 @@ +There doesn't seem to be a valid reason for this restriction, and it doesn't +impede building anyway. + +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -40,7 +40,7 @@ + # however macOS was broken and it's safe C API/ABI-wise to build against 1.21.6 + # (see oldest-supported-numpy issues gh-28 and gh-45) + "numpy==1.21.6; python_version=='3.10' and (platform_system!='Windows' and platform_machine!='loongarch64') and platform_python_implementation != 'PyPy'", +- "numpy==1.23.2; python_version=='3.11' and platform_python_implementation != 'PyPy'", ++ "numpy>=1.23.2; python_version=='3.11' and platform_python_implementation != 'PyPy'", + + # For Python versions which aren't yet officially supported, + # we specify an unpinned NumPy which allows source distributions diff --git a/srcpkgs/python3-scipy/template b/srcpkgs/python3-scipy/template index 1871a8a30a9..e0e0fdec2aa 100644 --- a/srcpkgs/python3-scipy/template +++ b/srcpkgs/python3-scipy/template @@ -1,26 +1,35 @@ # Template file for 'python3-scipy' pkgname=python3-scipy -version=1.10.1 +version=1.11.0 revision=1 -build_style=python3-module -build_helper="numpy" -make_check_args="--force" -hostmakedepends="gcc-fortran python3-setuptools - pythran python3-Cython python3-pybind11" -makedepends="python3-devel python3-pybind11 +build_style=meson +build_helper="python3" +hostmakedepends="python3-build python3-installer python3-meson-python + python3-wheel python3-Cython python3-pybind11 pythran python3-numpy + gcc-fortran pkg-config" +makedepends="python3-devel python3-pybind11 python3-numpy pythran $(vopt_if openblas openblas-devel lapack-devel)" depends="python3-numpy" -checkdepends="python3-pytest-xdist python3-pooch" short_desc="Scientific library for Python3" maintainer="Andrew J. Hesford " license="BSD-3-Clause" homepage="https://scipy.org/scipylib/" -distfiles="https://github.com/scipy/scipy/releases/download/v${version}/scipy-${version}.tar.gz" -checksum=2cf9dfb80a7b4589ba4c40ce7588986d6d5cebc5457cad2c2880f6bc2d42f3a5 -make_check="ci-skip" # Tests require downloaded data and take a long time +distfiles="${PYPI_SITE}/s/scipy/scipy-${version}.tar.gz" +checksum=f9b0248cb9d08eead44cde47cbf6339f1e9aa0dfde28f5fb27950743e317bd5d +make_check="no" # Tests need an installed copy to run and meson makes this tough build_options="openblas" +if [ "$CROSS_BUILD" ]; then + _pybind11_dir="${py3_sitelib}/pybind11" + configure_args="--cross-file=python.cross" + export PKG_CONFIG_PATH="${XBPS_CROSS_BASE}/${_pybind11_dir}/share/pkgconfig" + # pybind11 uses a path relative to the pkgconfig file to set $prefix, + # which causes the wrapper to double-include $XBPS_CROSS_BASE; override + # so that the wrapper properly points to the right location + export PKG_CONFIG_PYBIND11_PREFIX="/${_pybind11_dir}" +fi + case "$XBPS_TARGET_MACHINE" in x86_64*|i686*|aarch64*|armv[67]*|ppc64*) # Prefer accelerated routines where available @@ -36,29 +45,34 @@ if [ "$build_option_openblas" ]; then esac fi -# Tell numpy to build in parallel -export NPY_NUM_BUILD_JOBS="${XBPS_MAKEJOBS}" +pre_patch() { + if [ "${CROSS_BUILD}" ]; then + # Meson can't tolerate $CC with arguments as set by the build helper + CC="${XBPS_CROSS_TRIPLET}-gcc" + # CXX needs to know where to find Python headers + CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}" + fi +} -pre_build() { - # Find the right linear algebra subroutines on the target arch - : > site.cfg - for _blaslib in $(vopt_if openblas openblas "lapack blas"); do - cat >> site.cfg <<-EOF - [$_blaslib] - libraries = ${_blaslib} - include_dirs = ${XBPS_CROSS_BASE}/usr/include - library_dirs = ${XBPS_CROSS_BASE}/usr/lib - runtime_library_dirs = ${XBPS_CROSS_BASE}/usr/lib +post_patch() { + if [ "$CROSS_BUILD" ]; then + local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}" + cat > python.cross <<-EOF + [properties] + numpy-include-dir = '${_xpy}/numpy/core/include' + pythran-include-dir = '${_xpy}/pythran' EOF - done + fi } -do_check() { - touch .coveragerc - python3 ./runtests.py --verbose ${makejobs} +do_build() { + # Use the build directory already configured by xbps-src for meson + python3 -m build --no-isolation --wheel \ + -Cbuilddir="./build" -Ccompile-args="${makejobs}" . } -post_install() { - rm ${DESTDIR}/${py3_sitelib}/scipy/*.txt +do_install() { + python3 -m installer --destdir "${DESTDIR}" \ + --no-compile-bytecode dist/*.whl vlicense LICENSE.txt }