# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=python-blosc2
pkgver=3.11.1
pkgrel=1
pkgdesc='Wrapper for the blosc2 compressor'
arch=('x86_64' 'aarch64')
url='https://github.com/Blosc/python-blosc2'
license=('BSD-3-Clause')
depends=(
  'blosc2'
  'glibc'
  'python'
  'python-msgpack'
  'python-ndindex'
  'python-numexpr'
  'python-numpy'
  'python-platformdirs'
  'python-py-cpuinfo'
  'python-requests'
)
makedepends=(
  'cmake'
  'cython'
  'git'
  'ninja'
  'python-build'
  'python-installer'
  'python-scikit-build-core'
  'python-setuptools'
)
checkdepends=(
  'python-psutil'
  'python-pytest'
  'python-pytorch'
)
source=("$pkgname::git+$url#tag=v$pkgver")
sha512sums=('1aa5941fc945cdc175b5ddaf08300c0e22111986ce1f91ff078c4edb82feddcd007a8a15cf022e72e6fe519fb64e65a4ab524bfcf23d0600b4dc1d2ca84a0891')
b2sums=('35475fd215573edfcb335903459490f60d6ff862c53210f91c2de5688210e824d789e112215d29da2655c7de14f4c9c5306f8dac21b527322c0b7095e008e078')

build() {
  cd $pkgname
  export CMAKE_ARGS="-DUSE_SYSTEM_BLOSC2=ON"
  python -m build --wheel --no-isolation
}

check() {
  cd $pkgname
  python -m venv venv-test --system-site-packages
  ./venv-test/bin/python -m installer dist/*.whl
  # Deselect tests failing since v3.4.0, not sure why
  ./venv-test/bin/python -m pytest \
    --deselect tests/ndarray/test_lazyexpr.py::test_broadcasting \
    --deselect tests/ndarray/test_lazyexpr.py::test_chain_expressions \
    --deselect tests/ndarray/test_lazyexpr.py::test_chain_persistentexpressions \
    --deselect tests/ndarray/test_reductions.py::test_broadcast_params \
    --deselect tests/ndarray/test_reductions.py::test_fast_path \
    --deselect tests/ndarray/test_reductions.py::test_save_version1 \
    --deselect tests/ndarray/test_reductions.py::test_save_version2 \
    --deselect tests/ndarray/test_reductions.py::test_save_version3 \
    --deselect tests/ndarray/test_reductions.py::test_save_version4
}

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