# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
maintainer="Marian Buschsieweke <marian.buschsieweke@posteo.net>"
pkgname=py3-codespell
_pkgname=${pkgname#py3-}
pkgver=2.4.1
pkgrel=0
pkgdesc="Fix common misspellings in text files, primarily source code"
url="https://github.com/codespell-project/codespell/"
arch="noarch"
license="GPL-2.0-only"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	"
checkdepends="
	py3-pytest-cov
	py3-pytest-dependency
	"
depends="py3-chardet"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/codespell-project/codespell/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

build() {
	SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver \
	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

	# tests want to run bin/codespell
	PATH="$builddir/.testenv/bin:$PATH" .testenv/bin/python3 -m pytest
}

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

sha512sums="
8ed8fc1329445ffd3bf177289a5697f346c742d3cd3aa5b8bee1a20d97f4ce6656ff75bd986dda8413342cce5e52314f3b982185bd6d4a5de08f07837702ee15  py3-codespell-2.4.1.tar.gz
"
