# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=python-isal
pkgver=1.8.0
pkgrel=1
pkgdesc='Faster zlib and gzip compatible compression and decompression by providing python bindings for the isa-l library'
arch=(x86_64 aarch64)
url=https://github.com/pycompression/python-isal
license=(PSF-2.0)
depends=(
  glibc
  isa-l
  python
)
makedepends=(
  git
  nasm
  python-build
  python-installer
  python-setuptools
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-pytest
  python-pytest-timeout
  python-tests
)
source=(
  "git+$url.git#tag=v$pkgver"
  "git+https://github.com/intel/isa-l.git"
)
sha256sums=('33408c552fae7a31f7e7c71f63a26935a6a694c623a278daa976c66cb72ca299'
            'SKIP')

prepare() {
  cd $pkgname
  git submodule init
  git config submodule.src/isal/isa-l.url "$srcdir/isa-l"
  git -c protocol.file.allow=always submodule update \
    src/isal/isa-l
}

build() {
  cd $pkgname
  export SETUPTOOLS_SCM_PRETEND_VERSION="$pkgver"
  export PYTHON_ISAL_LINK_DYNAMIC=1
  python -m build --wheel --no-isolation
}

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

package() {
  cd $pkgname
  python -m installer --destdir="$pkgdir" dist/*.whl
}
