# Maintainer: David Runge <dvzrv@archlinux.org>

_name=svglib
pkgname=python-svglib
pkgver=1.1.0
pkgrel=2
pkgdesc="Read SVG files and convert them to other formats"
arch=('any')
url="https://github.com/deeplook/svglib"
license=('LGPL3')
depends=('python-lxml' 'python-reportlab' 'python-tinycss2' 'python-cssselect2')
makedepends=('python-setuptools')
checkdepends=('python-pillow' 'python-pytest')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('cf510a4792b5243db3e4c5fb1df9a3aae77454d31e65fb3d8cb11195a39c9528a5ecdedf75f364923af8f052cc2758bace92372b8758025a5bbcfe0846a34a92')
b2sums=('bd1c299a2504c271b8d682b4c4e0d7d4d6c5d66e6aa085a4216c32c8dcdf97912a89c4abab546ff3e51f6a756ea6191d118feb601449610ba88457c17cc3cdea')

prepare() {
  mv -v "${_name}-$pkgver" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="build:${PYTHONPATH}"
  # disable tests that download stuff and that are broken
  pytest -v -k "not TestWikipediaSymbols and not TestWikipediaFlags and not test_png_in_svg and not test_external_svg_in_svg"
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
                          --optimize=1 \
                          --root="${pkgdir}"
  install -vDm 644 {CHANGELOG,CONTRIBUTORS,README}.rst \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
