# Maintainer: Robin Candau <antiz@archlinux.org>
# Contributor: Lorenz Steinert <lsteinert+aur@uraziel.de>

pkgname=python-cross-web
_pkgname=cross-web
pkgver=0.4.1
pkgrel=1
pkgdesc="A universal web framework adapter for Python that lets you write code once and use it across multiple web frameworks"
url="https://github.com/usecross/cross-web"
arch=('any')
license=('MIT')
depends=('python' 'python-typing_extensions')
makedepends=('python-build' 'python-installer' 'python-hatchling' 'python-wheel')
checkdepends=('python-pytest' 'python-pytest-asyncio')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('505f4e387b75a08dfc9be28a40812733336f41f662477ea2531702e1817bb329')

build() {
	cd "${_pkgname}-${pkgver}"
	python -m build --wheel --no-isolation
}

check() {
	cd "${_pkgname}-${pkgver}"
	python -m venv --system-site-packages test-env
	test-env/bin/python -m installer dist/*.whl
	PATH="${PWD}/test-env/bin:${PATH}" test-env/bin/python -m pytest \
		-m "not aiohttp" --ignore=tests/request/test_aiohttp.py \
		-m "not chalice" --ignore=tests/request/test_chalice.py \
		-m "not django" --ignore=tests/request/test_django.py \
		-m "not fastapi" --ignore=tests/response/test_fastapi.py --ignore=tests/response/test_response_to_fastapi.py \
		-m "not flask" --ignore=tests/request/test_flask.py \
		-m "not litestar" --ignore=tests/request/test_litestar.py \
		-m "not quart" --ignore=tests/request/test_quart.py \
		-m "not sanic" --ignore=tests/request/test_sanic.py \
		-m "not starlette"
}

package() {
	cd "${_pkgname}-${pkgver}"
	python -m installer -d "${pkgdir}" dist/*.whl

	install -Dm 644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
