# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: David Verelst <david dot verelst at gmail com>
# Contributor: richli

pkgname=python-shapely
pkgver=2.1.1
pkgrel=1
pkgdesc="Manipulation and analysis of geometric objects in the Cartesian plane"
arch=(x86_64 aarch64)
url="https://pypi.python.org/pypi/Shapely"
license=(BSD)
depends=(geos python)
optdepends=('python-numpy: for shapely.vectorized submodule')
makedepends=(python-build python-installer python-setuptools python-wheel python-numpy cython)
checkdepends=(python-pytest)
source=("https://pypi.io/packages/source/s/shapely/shapely-${pkgver}.tar.gz")
sha512sums=('dec996dad131b60a7d87f8481e7e44e069adc9264220b90848a1818b36c356cc272b03b6b652c6c413112c441bdc6fcae1a690e7e830c42c31973e8e11d58298')

build() {
  cd shapely-$pkgver
  CFLAGS+=" -Wno-incompatible-pointer-types" \
  python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
  local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  cd shapely-$pkgver/build/lib.linux-${CARCH}-cpython-${python_version}
  PYTHONPATH="$PWD" pytest -vv --color=yes
}

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