# Maintainer: fossdd <fossdd@pwned.life>
pkgname=py3-awscrt
pkgver=0.23.3
pkgrel=0
pkgdesc="Python bindings for the AWS Common Runtime"
url="https://github.com/awslabs/aws-crt-python"
# s390x: big endian is explicitly unsupported
arch="all !s390x"
license="Apache-2.0"
# use the cpp one to just pull the aws stack
makedepends="
	aws-crt-cpp-dev
	openssl-dev
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	samurai
	"
checkdepends="py3-websockets"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-crt-python/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/aws-crt-python-$pkgver"
options="net" # tests need internet

case "$CARCH" in
arm*|aarch64|ppc64le|loongarch64)
	# too slow at running tests / fix later
	options="$options !check"
	;;
esac
prepare() {
	default_prepare

	# by default it's just 1.0.0.dev0
	echo "__version__ = '$pkgver'" >> awscrt/__init__.py
}

build() {
	export AWS_CRT_BUILD_USE_SYSTEM_LIBCRYPTO=1
	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 unittest discover test
}

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

sha512sums="
408ee48708ef1b810c14beeb915967e1f82fd04b15a1eb45e13498d70d271e1fae242d3c7abba0a82a6746bbc64d15e852cb395a88d4fc9cdbd30a1e7d1e8631  py3-awscrt-0.23.3.tar.gz
"
