# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=vdirsyncer
pkgver=0.19.2
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
}

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

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

sha512sums="
056c58011d0a054a8cc215e9eabc706dfffb7d38deab5ae47311565b3bdb6de7a4772e97a0a50cdce33c82b09d559f1ec9cf9c84746553badf1d25791c7e08ce  vdirsyncer-0.19.2.tar.gz
"
