# Contributor: Carlos Aznarán <caznaranl@uni.pe>
# Contributor: PumpkinCheshire <me at pumpkincheshire dot com>
# Contributor: alienzj <alienchuj@gmail.com>

pkgname=python-pygraphviz
pkgver=1.14
pkgrel=5
pkgdesc='Python interface to Graphviz'
arch=(x86_64 aarch64)
url=https://pygraphviz.github.io
license=(BSD-3-Clause)
depends=(
  graphviz
  python
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
source=(
  "$pkgname::git+https://github.com/pygraphviz/pygraphviz#tag=pygraphviz-$pkgver"
  graphviz-13.patch
)
sha512sums=('01e6620e063a5b79320637d9272189c97cb93925cab41746eb660ef2ce8f1741a02962a9b0687a661ea85f5f6018454e4f39f7cfeb99b0e032aa548d87f626de'
            '947a03f8ebebab4906b1249bb7612cca2b29cf35cb8953fd0d7e8db506c294be00e181debe10ff66aa740cc61d2054248560bf9a622dd06a1c73b822eaddda64')
b2sums=('9013cd96ab59fed0dca920b1c70294fd12654f82ca4c167c24bbe6c6ed76ec50c10eab5e082f7eb77ec0cfea31a120d03f1771a3ae4b0dacf5b95a1585dfb0a2'
        'b6f8656f6713a557c071277ff7da257c663fd7b6311a9e6ca3b8cd8be1f2f30b6d4062b17ed12f149c0d56857a3f644dcf030ddd25143639e9328f07ce62d1c9')

prepare() {
  cd "$pkgname"

  # Fix build with graphviz 13
  patch -p1 -i "$srcdir/graphviz-13.patch"
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

package() {
  cd "$pkgname"

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

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
