# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=py3-lsp-jsonrpc
pkgver=1.1.2
pkgrel=1
pkgdesc="asynchronous JSON RPC server, fork of python-jsonrpc-server"
url="https://github.com/python-lsp/python-lsp-jsonrpc"
arch="noarch"
license="MIT"
depends="py3-ujson"
makedepends="py3-setuptools py3-gpep517 py3-installer py3-wheel py3-setuptools_scm"
checkdepends="py3-pytest py3-mock"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/python-lsp/python-lsp-jsonrpc/archive/v$pkgver.tar.gz"
builddir="$srcdir/python-lsp-jsonrpc-$pkgver"

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION="$pkgver"
	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_writer_message broken with ujson:
	# https://github.com/python-lsp/python-lsp-jsonrpc/issues/6
	.testenv/bin/python3 -m pytest -c test -k 'not test_writer_bad_message'
}

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

sha512sums="
e4262831a3478fceebcc51807e83a2b4b01517065768a0a9f8638980a2c00c9d56de6fc2632ff66fa8dc9ee3b3bd98716efb1838a9b7656e74bdb555bd16e459  py3-lsp-jsonrpc-1.1.2.tar.gz
"
