# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Henrik Riomar <henrik.riomar@gmail.com>
pkgname=py3-nats
_pkgname=nats.py
pkgver=2.9.0
pkgrel=0
pkgdesc="Python3 client for NATS"
url="https://github.com/nats-io/nats.py"
arch="noarch"
license="Apache-2.0"
checkdepends="
	nats-server
	py3-pytest
	py3-pytest-cov
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
depends="
	py3-aiohttp
	python3
	"
subpackages="$pkgname-pyc"
source="https://github.com/nats-io/nats.py/archive/v$pkgver/nats.py-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

case "$CARCH" in
x86|armv7|armhf|s390x|ppc64le|riscv64|loongarch64)
	options="!check" ;; # no nats-server package
*) ;;
esac

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	# test_client: intermittently fails
	# test_js: failed since 2.7.2 rebuild, 2.9.0
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest \
		-k 'not test_client and not test_js'
}

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

sha512sums="
1f9bbd357321a4c2e5f9297fa5dfdb7658c224216406a3a7c10f4451b383cda13b52689384b334db21860c6dfef6170bacc8c47b0cd10e6f645bec24ff452f84  nats.py-2.9.0.tar.gz
"
