# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: SZanko, szanko at protonmail dot com
pkgname=python-shtab
pkgver=1.8.0
pkgrel=1
pkgdesc='Automagic shell tab completion for Python CLI applications'
arch=('any')
url='https://github.com/iterative/shtab'
license=('Apache-2.0')
depends=('python')
makedepends=(
'git'
'python-build'
'python-installer'
'python-wheel'
'python-setuptools-scm'
)
#checkdepends=(
# 'python-pytest'
# 'python-pytest-timeout'
#)
source=(
"$pkgname::git+$url#tag=v$pkgver"
'remove-cov.patch'
)
sha512sums=('163371b7985cf08b048c1156b102036e05a3cae84e37dd5e84fdaf53e1a8717d1cbb1d5ab28313b425e9722fa113d32b7aed6051639dc64c92b290f3ff215b13'
'c1390c0c1140ed701a56394b44bc5a0497901811cfbc7b6185f964b773db7851a13c745fe8122705ee74bbcdb3ce7ff5e19a5b8cfcf20df6e32b28f0887cb18a')
b2sums=('1d75e2b9a7f70d46375339997254594afce9db467c8c1c249b7f37c8252e71f8b57d3be26f3fbaa63555b2cb9c82f16abbd1f07a59f8507275b946d21dc26faf'
'3d265e70111506165beddf031af0efb01ca62bd2d0b41af04e74f175db8b9fec6e1b31ad5dbba5d001d53d48313e581b3bbfa4d2ba7d1094cb983521a5b3c1d2')
prepare() {
cd "$pkgname"
patch -p1 -i "$srcdir/remove-cov.patch"
}
build() {
cd "$pkgname"
SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build --wheel --no-isolation
local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
# install to temporary directory
python -m installer --destdir="$PWD/tmp_install" dist/*.whl
export PYTHONPATH="$PWD/tmp_install$site_packages"
# generate shell completions
for shell in bash zsh; do
python -m shtab --print-own-completion "$shell" > "$shell.completion"
done
}
#check() {
# cd "$pkgname"
# pytest -v
#}
package() {
cd "$pkgname"
python -m installer --destdir="$pkgdir" dist/*.whl
# shell completions
install -vDm644 bash.completion "$pkgdir/usr/share/bash-completion/completions/shtab"
install -vDm644 zsh.completion "$pkgdir/usr/share/zsh/site-functions/_shtab"
# license
install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENCE
}