# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer:
pkgname=py-graphviz
pkgver=0.8.1
pkgrel=0
pkgdesc="Simple interface for Graphviz"
url="https://github.com/xflr6/graphviz"
arch="noarch"
license="MIT"
depends=""
makedepends="python2-dev python3-dev py-setuptools"
checkdepends="pytest"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
options="!check" #FIXME fails
source="$pkgname-$pkgver.tar.gz::https://github.com/xflr6/graphviz/archive/$pkgver.tar.gz"
builddir="$srcdir"/graphviz-$pkgver

build() {
	cd "$builddir"
	python2 setup.py --quiet build
	python3 setup.py --quiet build
}

check() {
	cd "$builddir"
	python2 run-tests.py
	python3 run-tests.py
}

package() {
	cd "$builddir"
	mkdir -p "$pkgdir"/usr/bin
}

_py2() {
	depends="${depends//py-/py2-}"
	_py python2
}

_py3() {
	depends="${depends//py-/py3-}"
	_py python3
}

_py() {
	local python="$1"
	local pyver="${1:6:1}"
	pkgdesc="$pkgdesc (for $python)"
	depends="$depends $python"
	install_if="$pkgname=$pkgver-r$pkgrel $python"

	cd "$builddir"
	$python setup.py --quiet install --prefix=/usr --root="$subpkgdir"
}

sha512sums="adfdf7d1546449114673e605f6f1ad90900b94c73d7a6dab0890cbc51dd9918d53f5d0d413d4446ec618eeb90e8ad2833de329dda3ec154909970e84a7243656  py-graphviz-0.8.1.tar.gz"
