# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: Bodor Dávid Gábor <david.gabor.bodor@gmail.com>
# Contributor: Andrzej Giniewicz <gginiu@gmail.com>

_name=scipy
pkgname=python-scipy
pkgver=1.13.1
pkgrel=2
pkgdesc='Open-source software for mathematics, science, and engineering'
arch=(x86_64 aarch64)
url='https://www.scipy.org/'
license=(BSD-3-Clause)
depends=(blas
         gcc-libs
         glibc
         lapack
         python
         python-numpy
         python-platformdirs
         python-pooch)
provides=(scipy)
makedepends=(cython
             gcc-fortran
             meson-python
             pybind11
             python-build
             python-installer
             python-pythran)
checkdepends=(python-hypothesis
              python-pytest)
optdepends=('python-pillow: for image saving module')
source=(https://github.com/scipy/scipy/releases/download/v$pkgver/$_name-$pkgver.tar.gz)
sha256sums=('095a87a0312b08dfd6a6155cbbd310a8c51800fc931b8c0b84003014b874ed3c')
options=(!lto) # crashes with numpy 2.0

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation --skip-dependency-check \
    -C setup-args=-Dblas=blas \
    -C setup-args=-Dlapack=lapack
}

check() {
  cd $_name-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  cd test-env
  bin/python -c "from scipy import test; test('full')"
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname
}
