# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-blis
pkgver=0.9.1
pkgrel=4
pkgdesc="Fast matrix-multiplication as a self-contained Python library"
url="https://github.com/explosion/cython-blis"
arch="x86_64 x86"
license="MIT"
depends="py3-numpy"
makedepends="
	cython
	py3-gpep517
	py3-numpy-dev
	py3-setuptools
	py3-wheel
	python3-dev
	"
checkdepends="py3-hypothesis py3-pytest"
subpackages="$pkgname-doc $pkgname-pyc"
source="blis-$pkgver.tar.gz::https://github.com/explosion/cython-blis/archive/v$pkgver.tar.gz"
#options="!check" # Disable checks as py3-hypothesis 5.x is not supported
builddir="$srcdir/cython-blis-$pkgver"

prepare() {
	default_prepare
	case "$CARCH" in
		x86_64) BLIS_ARCH=x86_64 ;;
		x86) BLIS_ARCH=generic ;;
		aarch64) BLIS_ARCH=cortexa53 ;;
	esac
	export BLIS_ARCH
}

build() {
	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

	# otherwise pytest picks up the local one,
	# which doesn't have the native shared library and fails
	cd .testenv/lib/python3.*/site-packages
	$builddir/.testenv/bin/python3 -m pytest
}

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

	install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}

sha512sums="
49ab87d80e082ce6ae1be24f1acd08e3bf75666eb978f0fb37e655e84e9d111d6ac0d6b1faaefec49cdbbc3c29c0d8d0d9acd96ba836319fef842950a5eca63c  blis-0.9.1.tar.gz
"
