# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py3-sphinxcontrib-programoutput
_pkgname=sphinxcontrib-programoutput
pkgver=0.17
pkgrel=5
pkgdesc="Sphinx programoutput extension"
url="https://sphinxcontrib-programoutput.readthedocs.io/en/latest/"
arch="noarch"
license="BSD-2-Clause"
depends="python3 py3-sphinx"
makedepends="py3-setuptools py3-gpep517"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/NextThought/$_pkgname/archive/$pkgver.tar.gz"

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

builddir="$srcdir"/$_pkgname-$pkgver

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	gpep517 install-wheel --destdir .testenv --prefix '' .dist/*.whl
	local sitedir="$(echo .testenv/lib/python3*/site-packages)"
	export PYTHONPATH="$sitedir:$PYTHONPATH"
	# https://github.com/OpenNTI/sphinxcontrib-programoutput/issues/61
	.testenv/bin/python3 -m pytest "$sitedir" \
		--deselect "$sitedir/sphinxcontrib/programoutput/tests/test_directive.py::TestDirective::test_shell_with_unexpected_return_code" \
		--deselect "$sitedir/sphinxcontrib/programoutput/tests/test_directive.py::TestDirective::test_unexpected_return_code"
}

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

sha512sums="
200f91e5e1f3f633dfe3255ff5d5c3f3da81aea1674a4c1325ca4d60c7a97a6cb35bbbab3484d8b8920dc9723b7c480c360e58ed6a772ba53ab46e84ecad5bef  py3-sphinxcontrib-programoutput-0.17.tar.gz
"
