# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=vdirsyncer
pkgver=0.19.3
pkgrel=2
pkgdesc="CLI Synchronization for CalDAV and CardDAV"
url="http://vdirsyncer.pimutils.org"
arch="noarch"
license="BSD-3-Clause"
depends="
	python3
	py3-aiohttp
	py3-aiostream
	py3-atomicwrites
	py3-click
	py3-click-log
	py3-requests
	py3-requests-toolbelt
	"
makedepends="
	py3-gpep517
	py3-installer
	py3-wheel
	py3-setuptools_scm
	py3-sphinx
	"
checkdepends="
	py3-aioresponses
	py3-pytest
	py3-pytest-asyncio
	py3-pytest-cov
	py3-pytest-httpserver
	py3-hypothesis
	py3-subtesthack
	py3-trustme
	py3-werkzeug
	"
subpackages="$pkgname-doc $pkgname-pyc $pkgname-google"
source="https://files.pythonhosted.org/packages/source/v/vdirsyncer/vdirsyncer-$pkgver.tar.gz"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
	PYTHONPATH="$PWD" sphinx-build -b man docs/ build/
}

check() {
	# test_request_ssl requires network
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	DETERMINISTIC_TESTS=true .testenv/bin/python3 -m pytest \
		--deselect tests/system/utils/test_main.py::test_request_ssl \
		--deselect tests/unit/utils/test_vobject.py::TestVobjectMachine::runTest
}

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

google() {
	mkdir -p "$subpkgdir"
	depends="py3-aiohttp-oauthlib"
}

sha512sums="
8651282302ad62b2bb6f7655429492dcff959cedc25e932d2e72deb2bb54406c6b5333fecdb14ae8c08ba3c20602856e8466198e24caee298fc9a08545fd3751  vdirsyncer-0.19.3.tar.gz
"
