# Maintainer:
# Contributor: Guillaume Horel <guillaume.horel@gmail.com>

_pyname=cramjam
pkgname=python-$_pyname
pkgver=2.8.3
pkgrel=2
pkgdesc='Thin Python bindings to de/compression algorithms in Rust'
arch=(x86_64 aarch64)
url='https://github.com/milesgranger/pyrus-cramjam'
license=(MIT)
depends=(python)
checkdepends=(python-hypothesis python-pytest python-numpy)
makedepends=(python-installer maturin rust patchelf)
source=(https://files.pythonhosted.org/packages/source/${_pyname::1}/$_pyname/$_pyname-$pkgver.tar.gz)
sha256sums=('6b1fa0a6ea8183831d04572597c182bd6cece62d583a36cde1e6a86e72ce2389')
options=(!lto)

build(){
  cd $_pyname-$pkgver
  maturin build --release --strip --interpreter python
}

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

  cd $_pyname-$pkgver
  python -m installer --destdir=test_dir target/wheels/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -v "${_pyname}-python/tests"
}

package(){
  cd $_pyname-$pkgver
  python -m installer --destdir="$pkgdir" target/wheels/*.whl
  install -vDm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
