# Template file for 'khal'
pkgname=khal
version=0.10.5
revision=2
build_style=python3-module
hostmakedepends="python3-setuptools python3-Sphinx python3-sphinxcontrib
 python3-click python3-click-log python3-configobj python3-dateutil
 python3-icalendar python3-pytz python3-tzlocal python3-urwid python3-xdg
 python3-atomicwrites"
depends="python3-click python3-click-log python3-configobj python3-dateutil
 python3-icalendar python3-pytz python3-tzlocal python3-urwid python3-xdg
 python3-atomicwrites"
checkdepends="python3-pytest python3-freezegun vdirsyncer $depends"
short_desc="Command-line calendar build around CalDAV"
maintainer="Anachron <gith@cron.world>"
license="MIT"
homepage="http://lostpackets.de/khal/"
changelog="https://raw.githubusercontent.com/pimutils/khal/master/CHANGELOG.rst"
distfiles="${PYPI_SITE}/k/khal/khal-${version}.tar.gz"
checksum=4eefb7ac302a26d8606db392817587a4ed94c27a15bf2ea211614a464fcf0c76
make_check=ci-skip # some tests fail when running as root

pre_build() {
	vsed -i setup.py \
		-e '/setup_requires=/d' \
		-e "s|use_scm_version=.*|version='${version}',|"
}

post_install() {
	vlicense COPYING

	local _pypath="${DESTDIR}/${py3_sitelib}"
	if [ "$CROSS_BUILD" ]; then
		_pypath="${_pypath}:${XBPS_CROSS_BASE}/${py3_lib}"
	fi

	for sh in bash fish zsh; do
		PYTHONPATH="${_pypath}" _KHAL_COMPLETE="${sh}_source" $DESTDIR/usr/bin/khal > "khal.${sh}"
		vcompletion "khal.${sh}" $sh
	done
	vsconf khal.conf.sample
	cd doc/
	PYTHONPATH="${_pypath}" make man
	vman build/man/khal.1
}
