# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Eivind Uggedal <eivind@uggedal.com>
# Maintainer: Steven Guikal <void@fluix.one>
pkgname=py3-wtforms
pkgver=3.1.2
pkgrel=1
pkgdesc="Flexible forms validation and rendering library"
url="https://wtforms.readthedocs.io/"
arch="noarch"
license="BSD-3-Clause"
depends="python3 py3-markupsafe"
makedepends="py3-babel py3-gpep517 py3-hatchling"
checkdepends="py3-email-validator py3-pytest"
subpackages="$pkgname-lang $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/wtforms/wtforms/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/wtforms-$pkgver"

replaces="py-wtforms" # Backwards compatibility
provides="py-wtforms=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	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
	.testenv/bin/python3 -m pytest
}

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

lang() {
	local pythonpath="$(python3 -c \
		"from sysconfig import get_path; print(get_path('platlib'))")"

	langdir="$pythonpath"/wtforms/locale
	default_lang
}

sha512sums="
90120caa2e303c680177a6662e418e06c958c72c73f5bea0358381be9f674d2a850e81269772ae4e50db7cd3a03697a8b8e766a9b9291ff84aaa4ad78361a276  py3-wtforms-3.1.2.tar.gz
"
