# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=py3-sphinxcontrib-plantuml
_pkgname=plantuml
pkgver=0.30
pkgrel=0
pkgdesc="PlantUML for Sphinx"
url="https://github.com/sphinx-contrib/plantuml"
# x86, armv7, armhf: missing java-jre (dependency of plantuml)
# riscv64, ppc64le: missing plantuml
arch="noarch !x86 !riscv64 !ppc64le !armv7 !armhf"
license="BSD-2-Clause"
depends="
	plantuml
	py3-sphinx
	"
makedepends="
	py3-setuptools
	py3-gpep517
	py3-wheel
	"
checkdepends="
	py3-flake8
	py3-pillow
	py3-pytest
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/sphinx-contrib/plantuml/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

# only check with LaTeX PDF generation on x86_64. LaTeX is huge to install
# and not available on every architecture.
case "$CARCH" in
	x86_64)
		checkdepends="$checkdepends texlive-most"
		_pytest_flags=""
		;;
	*)
		_pytest_flags="--deselect tests/test_functional.py::test_buildlatex_simple_with_pdf"
		;;
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
	.testenv/bin/python3 -m pytest $_pytest_flags
}

package() {
	gpep517 install-wheel --destdir "$pkgdir" \
		.dist/*.whl
}

sha512sums="
e85c6332d26d09531c961f8026c72cd82ff4a31700a38cb8285f24d942340700012c08cc1f87a86389b71bfc5d32164586407b5c6777cc94d4d0022c9872ee3a  py3-sphinxcontrib-plantuml-0.30.tar.gz
"
