# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=py3-cairosvg
_pyname=CairoSVG
pkgver=2.7.1
pkgrel=2
pkgdesc="Cairo-based SVG renderer for python"
url="https://cairosvg.org/"
arch="noarch"
license="LGPL-3.0-or-later"
depends="
	py3-cairocffi
	py3-cssselect2
	py3-defusedxml
	py3-pillow
	py3-tinycss2
"
makedepends="
	cairo-dev
	python3-dev
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="py3-pytest"
_pypiprefix="${_pyname%"${_pyname#?}"}"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/$_pypiprefix/$_pyname/$_pyname-$pkgver.tar.gz"
builddir="$srcdir"/CairoSVG-$pkgver

replaces="py-cairosvg" # Backwards compat
provides="py-cairosvg=$pkgver-r$pkgrel" # Backwards compat

# secfixes:
#   2.7.0-r0:
#     - CVE-2023-27586
#   2.5.1-r0:
#     - CVE-2021-21236

prepare() {
	default_prepare

	mkdir test_non_regression/cairosvg_reference/
	cp -a $(ls -1 . | grep -v test_non_regression) test_non_regression/cairosvg_reference/
}

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
}

sha512sums="
fd2cdf38b6ee7860ded728694de8cb413d9442939e60501f7657e2dc43a16b6c6c863faa88a15ea001b7ee7949b2d441bcf609b1d64a49f3091573e14e8b1d92  CairoSVG-2.7.1.tar.gz
"
