# Contributor: Oleg Titov <oleg.titov@gmail.com>
maintainer="Oleg Titov <oleg.titov@gmail.com>"
pkgname=py3-zimscraperlib
pkgver=3.4.0
pkgrel=0
pkgdesc="Collection of python code to re-use across python-based scrapers"
url="https://github.com/openzim/python-scraperlib"
arch="noarch"
license="GPL-3.0-or-later"
depends="
	ffmpeg
	gifsicle
	py3-iso639-lang
	py3-pillow
	py3-six
	wget
	"
makedepends="
	py3-gpep517
	py3-hatch-openzim
	py3-hatchling
	py3-wheel
	"
checkdepends="
	py3-babel
	py3-beautifulsoup4
	py3-colorthief
	py3-libzim
	py3-lxml
	py3-magic
	py3-optimize-images
	py3-piexif
	py3-pytest
	py3-pytest-cov
	py3-pytest-httpbin
	py3-resizeimage
	py3-requests
	py3-wsgiprox
	yt-dlp-core
	"
subpackages="$pkgname-pyc"
source="py3-zimscraperlib-$pkgver.tar.gz::https://github.com/openzim/python-scraperlib/archive/refs/tags/v$pkgver.tar.gz"
options="net" # Required for tests
builddir="$srcdir/python-scraperlib-$pkgver"

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

	# some tests may fail, so disable them
	# https://github.com/openzim/python-scraperlib/issues/114
	.testenv/bin/python3 -m pytest \
		-k "not test_get_media_info[mp4-video.mp4-expected1]"` \
		   `" and not test_reencode_media[video.mkv-video.mp4-ffmpeg_args0-expected0]"` \
		   `" and not test_selocale_unsupported"` \
		   `" and not test_installed_script"` \
		   `" and not test_youtube_download_serial[https://vimeo.com/619427082-619427082_0]"` \
		   `" and not test_youtube_download_serial[https://vimeo.com/619427082-619427082_1]"` \
		   `" and not test_youtube_download_nowait"` \
		   `" and not test_youtube_download_contextmanager"` \
		   `" and not test_ogvjs_installed_script_missing_param"` \
		   `" and not test_ogvjs_installed_script_ok" \
		--ignore tests/download/test_download.py \
		--runslow --runinstalled \
		--cov=zimscraperlib \
		--cov-report=term --cov-report term-missing
}

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

sha512sums="
4f139df988a25bbc4551c134a3414a16d97d0cff791aff1c9c770f131d85e2d485b14f58e70fba8185b1ff4155507a46c946478ba527e60eeaa54e8446d9b52c  py3-zimscraperlib-3.4.0.tar.gz
"
