# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=py3-jsonschema
pkgver=4.22.0
pkgrel=0
pkgdesc="JSON Schema validation for Python"
url="https://github.com/python-jsonschema/jsonschema"
arch="noarch"
license="MIT"
depends="
	py3-attrs
	py3-jsonschema-specifications
	py3-referencing
	py3-rpds-py
	"
makedepends="
	py3-gpep517
	py3-hatch-fancy-pypi-readme
	py3-hatch-vcs
	py3-hatchling
	py3-installer
	py3-wheel
	"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/j/jsonschema/jsonschema-$pkgver.tar.gz
	skip-license-test.patch
	"
builddir="$srcdir/jsonschema-$pkgver"
options="!check" # the tests take forever

replaces="py-jsonschema"                  # Backwards compatibility
provides="py-jsonschema=$pkgver-r$pkgrel" # Backwards compatibility

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
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/jsonschema-$pkgver-py3-none-any.whl

	rm -r "$pkgdir"/usr/lib/python*/site-packages/jsonschema/tests

	ln -s jsonschema "$pkgdir"/usr/bin/jsonschema-3
}

sha512sums="
72c9ffd1edf8820696d831062cfae2d38729935b32d12b7fa5171fefa3d38d495b588152c07224a5c9d1f4b9f97bd9b2aa7919d3d4ecdae0ba396e60e954b1c5  jsonschema-4.22.0.tar.gz
4e74925bfa689bb53840f31faed361463e82bb2fd16c86a90de7cbcd0d1d6949c81944bc60e8d2068a6043e1da64b62fd48a062d683e9b96d6bc9b6603b2ccd6  skip-license-test.patch
"
