# Maintainer: Frode Solheim <frode@fs-uae.net>

_realname=lhafile
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-lhafile")
pkgver=0.3.1
pkgrel=1
pkgdesc="LHA module for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/FrodeSolheim/python-lhafile"
msys2_references=(
  'purl: pkg:pypi/lhafile'
)
license=('spdx:BSD-3-Clause')
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")
source=(https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz)
sha256sums=('a66a091e61af569384844ed74bf76179c575e5d28bc88bf9bf5476a3397d077d')

build() {
  cp -r "${_realname}-${pkgver}" "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 -m755 -d "${pkgdir}${MINGW_PREFIX}/share/licenses/python-lhafile"
  install -m644 COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-lhafile/"
}
