# Contributor: Galen Abell <galen@galenabell.com>
maintainer="Hugo Osvaldo Barrera <hugo@whynothugo.nl>"
pkgname=khal
pkgver=0.13.0
pkgrel=0
pkgdesc="CLI calendar application build around CalDAV"
url="https://lostpackets.de/khal"
arch="noarch"
license="MIT"
options="net"
depends="
	py3-click
	py3-click-log
	py3-configobj
	py3-dateutil
	py3-icalendar
	py3-tz
	py3-tzlocal
	py3-urwid
	py3-xdg
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	py3-setuptools_scm
	py3-sphinx
	py3-sphinxcontrib-newsfeed
	bash
	"
checkdepends="py3-packaging py3-pytest py3-freezegun py3-hypothesis vdirsyncer"
subpackages="
	$pkgname-doc
	$pkgname-pyc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="https://files.pythonhosted.org/packages/source/k/khal/khal-$pkgver.tar.gz"
case "$CARCH" in
s390x)
	# E AssertionError: assert '09:30-10:30: Great Event' in ''
	# E  +  where '' = <Result okay>.output
	options="!check"
	;;
esac

build() {
	gpep517 build-wheel \
		--wheel-dir dist \
		--output-fd 3 3>&1 >&2
	make -C doc man PYTHONPATH="$PWD"
	for shell in bash zsh fish; do
		PYTHONPATH="$PWD" _KHAL_COMPLETE=${shell}_source python3 ./bin/khal >khal.$shell
	done
}

check() {
	# some locale tests fail
	python3 -m venv --clear --system-site-packages testenv
	testenv/bin/python3 -m installer dist/*.whl
	testenv/bin/python3 -m pytest \
		--deselect tests/cal_display_test.py::test_vertical_month_unicode \
		--deselect tests/cal_display_test.py::test_vertical_month_unicode_weekdeays \
		--deselect tests/cal_display_test.py::test_vertical_month_unicode_weekdeays_gr \
		--deselect tests/cal_display_test.py::test_vertical_month_abbr_fr
}

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

	install -Dm644 khal.bash \
		"$pkgdir"/usr/share/bash-completion/completions/khal
	install -Dm644 khal.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_khal
	install -Dm644 khal.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/khal.fish
}

sha512sums="
728240af85a16a37b462457e22b0f19dc980ba700d89c64a1ce3d34eae04adaaf941a080a10fc78fb2da4d514a067cef24860af9a215a1ffc54aaf9c06e57649  khal-0.13.0.tar.gz
"
