# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=py3-recurring-ical-events
pkgver=3.7.0
pkgrel=0
pkgdesc="Python library for recurrence of ical events based on icalendar"
url="https://github.com/niccokunzmann/python-recurring-ical-events"
arch="noarch"
license="LGPL-3.0-or-later"
depends="python3 py3-icalendar py3-tz py3-tzdata py3-x-wr-timezone"
makedepends="py3-gpep517 py3-hatchling py3-hatch-vcs"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/niccokunzmann/python-recurring-ical-events/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/python-recurring-ical-events-$pkgver"

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	# Hatch VCS supports adding formattable URLs to the version data, but the `commit_hash` field requires a git repo.
	sed -i '/{commit_hash}/d' pyproject.toml
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	# skip documentation tests; one has a random fail and another requires an extra dependency
	.testenv/bin/python3 -m pytest -k 'not document' \
		--ignore recurring_ical_events/test/test_readme.py
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	rm -r "$pkgdir"/usr/lib/python3.*/site-packages/recurring_ical_events/test
}

sha512sums="
c23f9d5aa7f68682ce23c65043ba681b785f2e599e9313928b8343fc913f29e0ef54f999fe9aab08aaaffd248e16015c60fea5f78f763ea61689654ba28a28c8  py3-recurring-ical-events-3.7.0.tar.gz
"
