# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=py3-lz4
pkgver=4.4.3
pkgrel=0
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="
b02899f3011453f77e99aa31c7dc717a7d0ca636475e9ead617196d906e3e2abcee511e84f68e9071b27227cad8ece7fb5f78c04bd8f44cc0959bb687b72e73f  lz4-4.4.3.tar.gz
"
