# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=py3-lz4
pkgver=4.3.3
pkgrel=1
pkgdesc="LZ4 Bindings for Python"
url="https://pypi.org/project/lz4"
arch="all"
license="BSD-3-Clause"
makedepends="
	linux-headers
	lz4-dev
	py3-gpep517
	py3-pkgconfig
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	python3-dev
	"
checkdepends="
	py3-coverage
	py3-psutil
	py3-pytest
	py3-pytest-cov
	py3-pytest-runner
	"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/l/lz4/lz4-$pkgver.tar.gz"
builddir="$srcdir/lz4-$pkgver"

# FIXME: check fails on s390x
if [ "$CARCH" = "s390x" ]; then
	options="!check"
fi

replaces="py-lz4" # Backwards compatibility
provides="py-lz4=$pkgver-r$pkgrel" # Backwards compatibility

prepare() {
	default_prepare
	rm lz4libs/lz4*.[ch]
}

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	export PYTHONPATH="$(echo .testenv/lib/python3*/site-packages/):$PWD"
	.testenv/bin/python3 -P -m pytest tests/block tests/frame
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
9bdacf6766cca5d1c59f0a0f795910da104ce51d4c43057c4c07fed98765881a702604d60d22a10dea937c4d683e3fcf07c26a6c7a7b5a15b45759fcedb55900  lz4-4.3.3.tar.gz
"
