# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>

_pkgname=graphviz
pkgname=python-graphviz
pkgver=0.20.3
pkgrel=1
pkgdesc='Simple Python interface for Graphviz'
arch=(any)
url="https://github.com/xflr6/$_pkgname"
license=(MIT)
depends=(graphviz
         python)
makedepends=(python-{build,installer,wheel}
             python-setuptools)
checkdepends=(python-pytest
              python-pytest-mock)
#source=("https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/${_pkgname}/${_pkgname}-${pkgver}.zip")
_archive="$_pkgname-$pkgver"
source=("$url/archive/$pkgver/$_archive.tar.gz")
sha256sums=('6ae51c891c539a639b2db0862049979ce08214786b4beecc817b386596db428c')

prepare() {
	cd "$_archive"
	# do not run python-coverage in unittests :/
	sed -i 's/--cov --cov-report=term --cov-report=html//' setup.cfg
	# don't add pointless dependency on python-mock needed on python 3.5
	sed -i '/mock_use_standalone_module/d' setup.cfg
}

build(){
	cd "$_archive"
	python -m build -wn
}

check() {
	cd "$_archive"
	# Tests disabled because of a regression in pytest 8.1. This started
	# failing with Python 3.11 but we need to be able to rebuild for
	# Python 3.12, so disabling tests fro now.
	# https://github.com/pytest-dev/pytest/issues/12123
	# python -m pytest
}

package() {
	cd "$_archive"
	python -m installer -d "$pkgdir" dist/*.whl
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE.txt
}
