# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname='dulwich'
pkgbase="python-${_realname}"
pkgname="python-${_realname}"
pkgver=1.2.15
pkgrel=1
pkgdesc='Pure-Python implementation of the Git file formats and protocols'
arch=('any')
url='https://www.dulwich.io'
msys2_repository_url='https://github.com/jelmer/dulwich'
msys2_changelog_url='https://github.com/jelmer/dulwich/blob/master/NEWS'
msys2_references=(
  'anitya: 6077'
  'archlinux: python-dulwich'
  'cpe: cpe:/a:dulwich_project:dulwich'
  'gentoo: dev-python/dulwich'
  'purl: pkg:pypi/dulwich'
)
license=('spdx:Apache-2.0 OR GPL-2.0-or-later')
depends=(
  'python'
  'python-urllib3'
)
makedepends=(
  'gcc'
  'python-build'
  'python-devel'
  'python-installer'
  'python-setuptools'
  'python-setuptools-rust'
  'rust'
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('e98f775601846fb4d44a384003e93c53c42b0c9796c8fe0cc3128b8e2e0bbf88')

build() {
  cd "${_realname}-${pkgver}"

  local link_arg
  link_arg="$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBPYTHON'))")"

  export RUSTFLAGS="-C link-arg=${link_arg}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${_realname}-${pkgver}"

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

  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
