# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=afew
pkgver=3.0.1
pkgrel=0
pkgdesc="initial tagging script for notmuch"
url="https://github.com/afewmail/afew"
arch="all"
license="ISC"
depends="
	py3-chardet
	py3-dkimpy
	py3-notmuch
	notmuch
"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-sphinx
	py3-wheel
"
checkdepends="
	py3-pytest
	py3-pytest-freezegun
"
subpackages="$pkgname-doc"
source="https://github.com/afewmail/afew/archive/$pkgver/afew-$pkgver.tar.gz"

build() {
	# https://github.com/afewmail/afew/issues/283
	echo "version = \"$pkgver\"" > "$builddir/afew/version.py"

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

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

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

sha512sums="
63c3bc25969458624434dd44cdc05f74a3f82172d6deb1875b22612b4dde6dc13a3be0d96a96bf91f43657cf0d88a6f1a29233cf9e0775402fe2efc04120a473  afew-3.0.1.tar.gz
"
