# Maintainer: Bruno Pagani <archange@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>

pkgname=python-rtree
pkgver=1.4.1
pkgrel=1
pkgdesc="Rtree: spatial index for Python GIS"
arch=(any)
url="https://rtree.readthedocs.io/en/latest/"
license=(MIT)
depends=(
  python
  spatialindex
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-numpy
  python-pytest
)
optdepends=('python-numpy: array-based bulk insert support')
source=("https://github.com/Toblerity/rtree/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('fd72fdcf63af6c5cf613d4bc9b7cb7de07fa9a654d692d7936b82ba6291cc7ce')

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
  test-env/bin/python -m pytest
}

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