# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=lastversion
pkgver=3.5.7
pkgrel=0
pkgdesc="CLI tool to find the latest stable version of a project"
url="https://lastversion.getpagespeed.com/"
arch="noarch"
license="BSD-2-Clause"
depends="
	py3-appdirs
	py3-beautifulsoup4
	py3-cachecontrol
	py3-dateutil
	py3-distro
	py3-feedparser
	py3-filelock
	py3-packaging
	py3-requests
	py3-tqdm
	py3-urllib3
	py3-yaml
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="py3-pytest"
options="net" # tests require network access
subpackages="$pkgname-pyc"
source="https://github.com/dvershinin/lastversion/archive/v$pkgver/lastversion-$pkgver.tar.gz"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	local allow_fail="no"
	case "$CARCH" in
	loongarch64)
		allow_fail="yes"
		;;
	esac

	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	# Running the ignored tests will exceed Github's
	# API rate limit for unauthenticated requests
	PATH="$builddir/.testenv/bin:$PATH" \
	.testenv/bin/python3 -m pytest \
		--ignore tests/test_github.py \
		--ignore tests/test_lastversion.py \
	|| [ "$allow_fail" = "yes" ]
}

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

sha512sums="
d0c51eb82121339224d7640e31a193306783ff1e445726aed8f8af73d99e37140b02ca4a4d0fe6127ffd7e16febcf0e6dbc1a9b4c6495ac501928b956fdd3b9f  lastversion-3.5.7.tar.gz
"
