# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Timothée Ravier <tim@siosm.fr>

pkgname=python-dulwich
_name=${pkgname#python-}
pkgver=0.22.1
pkgrel=1
pkgdesc='Pure-Python implementation of the Git file formats and protocols'
arch=('x86_64' 'aarch64')
url=https://www.dulwich.io
license=('GPL')
depends=('python-setuptools' 'python-urllib3')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools-rust'
  'python-wheel'
)
checkdepends=('python-gpgme' 'python-paramiko')
optdepends=(
  'python-fastimport: for fast-import support'
  'python-gpgme: for PGP signature support'
  'python-idna: for HTTPS support via urllib3'
  'python-paramiko: for use as the SSH implementation'
  'python-pyopenssl: for HTTPS support via urllib3'
  'python-pyinotify: to watch for changes to refs'
)
source=("git+https://github.com/jelmer/dulwich.git#tag=dulwich-$pkgver")
b2sums=('b142ffa03e209f987b23d18a1660a234642f8d499d336fca0b2bfb962b90d5db1d4a7432f1f2e104eecd2ae884a385b0786b83729ecbc9c8fe86f602f8746bf0')
#validpgpkeys=('DC837EE14A7E37347E87061700806F2BD729A457') # Jelmer Vernooĳ <jelmer@jelmer.uk>

prepare() {
  cd "$_name"
  # https://github.com/jelmer/dulwich/issues/1293
  git cherry-pick -n 36c2264a621b94a30aea68938fe94059487b9cdf
}

build() {
  cd "$_name"
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "$_name"
  PYTHONPATH="$PWD/dulwich:$PYTHONPATH" python -m unittest -v tests.test_suite
}

package() {
  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl
}
