# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=py3-a2wsgi
pkgver=1.10.7
pkgrel=0
pkgdesc="Convert WSGI app to ASGI app or ASGI app to WSGI app"
url="https://github.com/abersheeran/a2wsgi"
arch="noarch"
license="Apache-2.0"
depends="python3"
makedepends="py3-gpep517 py3-pdm-backend py3-wheel"
checkdepends="py3-pytest py3-httpx py3-pytest-asyncio py3-starlette"
subpackages="$pkgname-pyc"
source="https://github.com/abersheeran/a2wsgi/archive/refs/tags/v$pkgver/a2wsgi-$pkgver.tar.gz"
builddir="$srcdir/a2wsgi-$pkgver"

case "$CARCH" in
	# test suite blocked by py3-httpx
	armhf|ppc64le) options="!check" ;;
esac

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
	# test_baize_stream_response: baize not packaged + kinda bad
	.testenv/bin/python3 -m pytest \
		--deselect tests/test_asgi.py::test_baize_stream_response
}

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

sha512sums="
64415b88488c1f6652dc33ee2db4432d5827135e93786dc08aa8aff54a407e5a83bf574cba81920093a723e3114d37c770fd127932997240e7c573d1151c2895  a2wsgi-1.10.7.tar.gz
"
