# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-blis
pkgver=1.0.1
pkgrel=0
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/release-v$pkgver.tar.gz"
#options="!check" # Disable checks as py3-hypothesis 5.x is not supported
builddir="$srcdir/cython-blis-release-v$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="
7b8691d6c42a4f598796be587e182aef6c5f6ad1f2df0b118b97a45852ecac097a8e133b222d2feaded27cdc1fc2161c4ad51fe7fb64ca4c15497de58bc3f696  blis-1.0.1.tar.gz
"
