# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=khard
pkgver=0.19.1
pkgrel=1
pkgdesc="Console CardDAV client"
url="https://github.com/lucc/khard"
arch="noarch"
license="GPL-3.0-only"
depends="
	python3
	py3-atomicwrites
	py3-configobj
	py3-ruamel.yaml
	py3-unidecode
	py3-vobject
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-setuptools_scm
	py3-sphinx
	py3-wheel
	"
checkdepends="py3-pytest"
subpackages="$pkgname-doc $pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/k/khard/khard-$pkgver.tar.gz"

prepare() {
	default_prepare

	# Remove some dependencies from the sphinx config; we only generate the manpages, and
	# they don't require these to build.
	sed -i \
		-e '/autoapi.extension/d' \
		-e '/sphinx_autodoc_typehints/d' \
		doc/source/conf.py
}

build() {
	gpep517 build-wheel \
		--wheel-dir dist \
		--output-fd 3 3>&1 >&2
	make -C doc man
}

check() {
	python3 -m venv --clear --system-site-packages testenv
	testenv/bin/python3 -m installer dist/*.whl
	testenv/bin/python3 -m pytest -s
}

package() {
	python3 -m installer -d "$pkgdir" \
		dist/*.whl
	install -Dm644 doc/build/man/$pkgname.1 "$pkgdir"/usr/share/man/man1/$pkgname.1
	install -Dm644 doc/build/man/$pkgname.conf.5 "$pkgdir"/usr/share/man/man5/$pkgname.conf.5
}

sha512sums="
619678902abee2561f2cef8d525d9688269f9f4da244b1c5cf97a9c2f15f5d08f80d09bc08304dfe3a7ca44dd5082e0152c5dce82063b6f98ea12b961b34bdf4  khard-0.19.1.tar.gz
"
