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

_realname='patiencediff'
pkgname="python-${_realname}"
pkgver=0.2.19
pkgrel=1
pkgdesc='Patiencediff Python and C implementations'
arch=('i686' 'x86_64')
url='https://pypi.org/project/patiencediff/'
msys2_repository_url='https://github.com/breezy-team/patiencediff'
msys2_references=(
  'anitya: 138229'
  'archlinux: python-patiencediff'
  'gentoo: dev-python/patiencediff'
  'purl: pkg:pypi/patiencediff'
)
license=('spdx:GPL-2.0-or-later')
depends=('python')
makedepends=(
  'gcc'
  'python-build'
  'python-devel'
  'python-installer'
  'python-setuptools'
  'python-setuptools-rust'
)
source=("${_realname}-${pkgver}.tar.gz::https://github.com/breezy-team/patiencediff/archive/v${pkgver}.tar.gz")
sha256sums=('40d8606afc29b52243decc5f1a35432cffac7eafc49c5e0b1da862849e324471')

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

  local 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"
}
