# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=py3-hidapi
pkgver=0.14.0
pkgrel=2
pkgdesc="Cython interface for hidapi"
url="https://github.com/trezor/cython-hidapi"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	cython
	eudev-dev
	hidapi-dev
	libusb-dev
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/trezor/cython-hidapi/archive/$pkgver.tar.gz
	cython3.patch"
builddir="$srcdir/cython-hidapi-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--config-json '{"--build-option": ["--with-system-hidapi"]}' \
		--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 unittest -v
}

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

sha512sums="
50152578c2bc80e4b74f8a2ac0a3dbb8f5e3a5a44b6df0d81a4bc732e91171750b4e3aebce625ace7eb88e890da760a20d425eced50d065063846e9fe465858f  py3-hidapi-0.14.0.tar.gz
bd9d6f0b76b37c5adc945f2795d3abd744c8d35656548f30882f7ef120077caef947b7427f1d67d5c90a5292ec08578ed0bdcec6c24ea19fbe417074d85c343a  cython3.patch
"
