# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=python-cairosvg
_pkgname=CairoSVG
pkgver=2.7.1
pkgrel=4
pkgdesc='SVG converter based on Cairo. It can export SVG files to PDF, PostScript and PNG files'
arch=('any')
url='https://cairosvg.org'
license=('LGPL3')
depends=('python-cairocffi' 'python-cssselect2' 'python-defusedxml' 'python-pillow' 'python-tinycss2')
makedepends=('python-build' 'python-installer' 'python-pytest' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest')
replaces=('cairosvg')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Kozea/CairoSVG/archive/$pkgver.tar.gz")
sha512sums=('9929875da56cf585bce7cdaf75d256064c6a1322caf9fb1abafbfa5e0c3b8f317416e58bd2575c8d0a6d198da645b036f44643b29d841c0aef10e6b9adab6e9e')

prepare() {
  cd $_pkgname-$pkgver
  sed -i -e '/pytest-runner/d' -e '/--flake8/d' -e '/--isort/d' setup.cfg

  cp -r cairosvg test_non_regression/cairosvg_reference/
}

build() {
  cd $_pkgname-$pkgver

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd $_pkgname-$pkgver

  pytest
}

package() {
  cd $_pkgname-$pkgver

  python -m installer --destdir="$pkgdir" dist/*.whl
}
