# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-opt_einsum
pkgver=3.3.0
pkgrel=2
pkgdesc="Optimizing einsum functions in NumPy, Tensorflow, Dask, and more with contraction order optimization"
url="https://github.com/dgasmith/opt_einsum"
arch="noarch"
license="MIT"
depends="
	py3-numpy
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	py3-python-versioneer
	"
checkdepends="
	py3-pytest-cov
	py3-pytest-xdist
	"
subpackages="$pkgname-pyc"
source="https://github.com/dgasmith/opt_einsum/archive/v$pkgver/opt_einsum-$pkgver.tar.gz"
builddir="$srcdir/opt_einsum-$pkgver"

prepare() {
	default_prepare

	# unvendor
	rm versioneer.py
	sed -i "s/version=versioneer.*/version='$pkgver',/" setup.py
}

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
	.testenv/bin/python3 -m pytest -n auto
}

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

	rm -r "$pkgdir"/usr/lib/python*/site-packages/opt_einsum/tests
}

sha512sums="
3f1bebf25febc1e1a0aab6d87b56ac80642e7182604cca06dcffa8db02d84ad0eaa9b8d68093c7ef76a8a7eabe51798886f168ee32e9c59f12ff2de427b52baf  opt_einsum-3.3.0.tar.gz
"
