# Template file for 'khal'
pkgname=khal
version=0.14.0
revision=1
build_style=python3-pep517
# The first two tests get the path to the configuration file wrong in an
# xbps-src chroot, the last one fails only sometimes for an unknown reason.
make_check_args="
 --deselect tests/cli_test.py::test_configure_command
 --deselect tests/cli_test.py::test_configure_command_create_vdir
 --deselect tests/khalendar_utils_test.py::TestSpecial::test_recurrence_id_with_timezone
"
_rundeps="python3-click python3-click-log python3-configobj python3-dateutil
 python3-icalendar python3-pytz python3-tzlocal python3-urwid python3-xdg"
hostmakedepends="python3-setuptools_scm python3-Sphinx python3-sphinxcontrib $_rundeps"
depends="$_rundeps"
checkdepends="python3-pytest-xdist python3-freezegun python3-hypothesis
 vdirsyncer $depends python3-setuptools"
short_desc="Command-line calendar build around CalDAV"
maintainer="Orphaned <orphan@voidlinux.org>"
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=10df243204b7a898e0ff89617ed9fd604a73fa1b4d37aac77c4470ad7519e16c

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	# Some locale-related failures.
	make_check_args+=" --deselect tests/cal_display_test.py::test_vertical_month_unicode
	 --deselect tests/cal_display_test.py::test_vertical_month_unicode_weekdays
	 --deselect tests/cal_display_test.py::test_vertical_month_unicode_weekdays_gr
	 --deselect tests/cal_display_test.py::test_vertical_month_abbr_fr
	"
fi

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

	PYTHONPATH="${_pypath}" make -C doc man
	vman doc/build/man/khal.1
}
