# Maintainer: llm96 <llm96@fervidex.net>

_realname=ifstools
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.15
pkgrel=1
pkgdesc="Extractor for Konami IFS files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/mon/ifstools'
msys2_references=(
  'aur: python-ifstools'
  'purl: pkg:pypi/ifstools'
)
license=('spdx:MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
  "${MINGW_PACKAGE_PREFIX}-python-lxml"
  "${MINGW_PACKAGE_PREFIX}-python-kbinxml"
  "${MINGW_PACKAGE_PREFIX}-python-pillow"
  "${MINGW_PACKAGE_PREFIX}-python-tqdm"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
options=('!strip')
source=("https://github.com/mon/${_realname}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('8769698e224b6b85c51b9ebb83d55ccf0f7c41017dcb6d0b099d68204b1c9881')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

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

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

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

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