# Maintainer: Brad Pitcher <bradpitcher@gmail.com>
# Contributor: Carlos Aznarán <caznaranl@uni.pe>
# Contributor: Jelle van der Waa <jelle@archlinux.org>
_base=trimesh
pkgname=python-${_base}
pkgver=3.21.4
pkgrel=1
pkgdesc="Import, export, process, analyze and view triangular meshes"
arch=(any)
url="https://trimsh.org"
license=(MIT)
depends=(python-numpy)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-pytest python-scipy python-lxml python-shapely
  python-pillow python-rtree python-networkx python-jsonschema
  python-collada python-svg.path python-mapbox-earcut)
# openscad python-ezdxf
optdepends=('python-scipy: convex hulls'
  'python-networkx: graph operations'
  'python-lxml: handle XML better and faster than built- in XML'
  'python-shapely: vector path handling'
  'python-rtree: vector path handling'
  'python-svg.path: handle SVG format path strings'
  'python-sympy: do analytical math'
  'python-pillow: load images'
  'python-requests: network requests'
  'python-xxhash: hash ndarrays faster than built-in MD5/CRC'
  'python-jsonschema: validate JSON schemas like GLTF'
  'python-collada: parse collada/dae/zae files'
  'python-pyglet: preview windows'
  'python-msgpack: serialize into msgpack')
source=(${_base}-${pkgver}.tar.gz::https://github.com/mikedh/${_base}/archive/${pkgver}.tar.gz)
sha512sums=('749f208b91f55b2a9581fa953bd984fc71a7c54bcc3d00ad1df8af2489911e966d2821dcff3d673e8ba55a83c9cce75625aaaeeddff817a16bb09b82b2bca549')

build() {
  cd ${_base}-${pkgver}
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd ${_base}-${pkgver}
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest tests # unittest discover tests
}

package() {
  cd ${_base}-${pkgver}
  PYTHONPYCACHEPREFIX="${PWD}/.cache/cpython/" python -m installer --destdir="${pkgdir}" dist/*.whl
  install -Dm 644 LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}"
}