# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: William Rea <sillywilly@gmail.com>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>

pkgname=python-pyx
pkgver=0.16
pkgrel=5
pkgdesc='Python library for the creation of PostScript and PDF files'
arch=('any')
url="https://pyx-project.org/"
license=('GPL')
depends=('python' 'texlive-latex')
makedepends=('python-setuptools')
checkdepends=('ghostscript' 'python-pillow' 'python-testfixtures' 'texlive-fontsrecommended')
source=("https://github.com/pyx-project/pyx/archive/refs/tags/$pkgver/$pkgname-$pkgver.tar.gz"
	"0001-test-fix-redirect-to-https.patch")
sha512sums=('2d85ffb4e2bbf88be0a2c77ff0865593794b15fe26424e590e6b2152691c425d27d11a7af5a2e6211774d01a9feaa4c3c00f922862ca5ca42e119f748b0300c2'
            'f2d4f052b1b80b3fa87fad7b9b9a06a0a3bcb2c5f1a464acdcf06fb868029d6f9fca415297c4ce607fba771b63a8ce2c95ea7f0454f5d8c52b8f4fd4866b430d')

prepare() {
  cd pyx-$pkgver/pyx/data
  # https://github.com/pyx-project/pyx/issues/39
  sed -i 's|methods = local internal pykpathsea kpsewhich|methods = local internal recursivedir pykpathsea kpsewhich|' pyxrc
  echo "recursivedir = /usr/share/texmf-dist/fonts/type1/public/amsfonts/" >> pyxrc

  # https://github.com/pyx-project/pyx/pull/43
  cd ${srcdir}/pyx-$pkgver/
  patch -Np1 -i ${srcdir}/0001-test-fix-redirect-to-https.patch
}

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

check() {
  cd pyx-$pkgver
  # doctest disabled: sphinx_selective_exclude isn't available in our repos
  make -C test unit functional svg
}

package() {
  cd pyx-$pkgver
  python setup.py install -O1 --root="$pkgdir"
}
