maintainer="Thomas Böhler <witcher@wiredspace.de>"
pkgname=linkchecker
_pkgname=LinkChecker
pkgver=10.5.0
pkgrel=0
pkgdesc="check links in web documents or full websites"
url="https://linkchecker.github.io/linkchecker/"
arch="noarch"
license="GPL-2.0-only"
depends="
	py3-argcomplete
	py3-beautifulsoup4
	py3-dnspython
	py3-pdfminer
	py3-requests
	py3-cryptography
	py3-pyftpdlib
	py3-openssl
"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	py3-hatchling
	py3-hatch-vcs
"
checkdepends="py3-pytest gettext"
subpackages="$pkgname-doc $pkgname-pyc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/linkchecker/linkchecker/releases/download/v$pkgver/linkchecker-$pkgver.tar.gz
"
builddir="$srcdir/$_pkgname-$pkgver"

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

check() {
	# Some tests are skipped due to the following reasons:
	# - binding to a socket is unavailable in tests
	# - GeoIP is heavily outdated (last release was in 2014, archived on pypi)
	# - not testing on a windows system
	# - test_safari_bookmarks_binary is flaky
	# - haven't bothered with the following (yet):
	#   - ClamAV
	#   - Word files

	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest \
		--ignore tests/test_locationinfo.py \
		--ignore tests/test_clamav.py \
		--ignore tests/checker/test_anchor.py \
		--ignore tests/checker/test_http.py \
		--ignore tests/checker/test_httpbin.py \
		--ignore tests/checker/test_viruscheck.py \
		-k "not test_word \
			and not test_nt_filename \
			and not test_norm_file2 \
			and not test_safari_bookmarks_binary"
}

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

	install -Dm644 -t "$pkgdir"/usr/share/doc/"$pkgname" COPYING README.rst
}

sha512sums="
4bd39965430ce478db803776790ef382064ccda2096a6a3b358673821b941a064a20fb67a0b25a353859d60e3624cde33fe2b6797657c76882d3b84c443e4a84  linkchecker-10.5.0.tar.gz
"
