# Maintainer: David Runge <dvzrv@archlinux.org>

_name=cytoolz
pkgname=python-cytoolz
pkgver=0.12.3
pkgrel=1
pkgdesc="Cython implementation of Toolz: High performance functional utilities"
arch=(x86_64 aarch64)
url="https://github.com/pytoolz/cytoolz/"
license=(BSD-3-Clause)
depends=(
  glibc
  python
  python-toolz
)
makedepends=(
  cython
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('b3c46182b1d93b4e862e8d37e7e49fd44126e7ce503b9a25f7d78ff79ee9eac938bf47a63fda6ff6adbb660efedf0eb07810fbc2e91d7a471cb0167bb7ef0ad6')
b2sums=('ad1b4474a5c5f954cabf38c447982fb44f4c57fb5637e827876fe3bf4fad7c947fb926087294d06769944a4d67d7cfea3e7f7cc68162ebd69cc9746a80fc5aad')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv test_dir/$_site_packages
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -frv "$pkgdir/$_site_packages/$_name/tests"
}
