# Maintainer: Keith Toh <ktprograms@gmail.com>
pkgname=py3-shtab
pkgver=1.7.1
pkgrel=0
pkgdesc="Automagic shell tab completion for Python CLI applications"
url="https://docs.iterative.ai/shtab/"
arch="noarch"
license="Apache-2.0"
depends="python3"
makedepends="py3-setuptools py3-setuptools_scm py3-wheel py3-gpep517 py3-installer"
checkdepends="py3-pytest py3-pytest-cov py3-pytest-timeout bash"
subpackages="$pkgname-doc $pkgname-pyc"
source="https://github.com/iterative/shtab/releases/download/v$pkgver/shtab-$pkgver.tar.gz"
builddir="$srcdir/shtab-$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
	.testenv/bin/python3 -m pytest
}

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

doc() {
	pkgdesc="$pkgdesc (documentation)"

	install -Dm644 "$builddir"/LICENCE "$subpkgdir"/usr/share/licenses/$pkgname/LICENSE
	mkdir -p "$subpkgdir"/usr/share/doc/$pkgname/examples
	cp "$builddir"/examples/* "$subpkgdir"/usr/share/doc/$pkgname/examples/
}

sha512sums="
749f21e5b4eba75744a270809b761e7c795e4404727f8e6da87f6620622e42dc6e35aa923c7f8df34bec27af45ec16496fdab11b8450edb09067df9c830ae219  shtab-1.7.1.tar.gz
"
