# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=pyfastbti
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}-git")
provides=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.r3.da01c14
pkgrel=6
pkgdesc='Python module for quickly handling BTI image files (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/LagoLunatic/PyFastBTI"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "git")
_gitcommit=da01c14562a4711e031fd0a01c52d2131035e228
source=("git+https://github.com/LagoLunatic/PyFastBTI#commit=${_gitcommit}")
sha256sums=('d4746021213ff11f63e59111954ce6081af775ff16419c3579b4fd542679ad6c')

pkgver() {
  cd $srcdir/PyFastBTI
  printf "0.r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cp -r "PyFastBTI" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}"/python-build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
