# Maintainer: Bruno Pagani <archange@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Andrzej Giniewicz <gginiu@gmail.com>
# Contributor: Sebastien Binet <binet@lblbox>

pkgname=python-numexpr
pkgver=2.14.1
pkgrel=3
pkgdesc="Fast numerical array expression evaluator for Python, NumPy, PyTables, pandas"
url="https://github.com/pydata/numexpr"
arch=(x86_64 aarch64)
license=(MIT)
depends=(
  glibc
  libgcc
  libstdc++
  python
  python-numpy
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
source=("$url/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
b2sums=('88f010494404fa3149ac1b523e00d33013fa1ee0dadd672233eacc659818995edd2c151e1c89934fa6ce2695161e7a2ba182bb6ab5b6e020438f27cd4b27f975')

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

check() {
  cd ${pkgname#python-}-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  local relative_site_packages=$(realpath --relative-to=/usr "$site_packages")
  cd "test-env/$relative_site_packages"
  pytest
}

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