# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=et-xmlfile
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.0.0
pkgrel=2
pkgdesc="A low memory library for creating large XML files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://et-xmlfile.readthedocs.io/"
msys2_references=(
  'purl: pkg:pypi/et-xmlfile'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-lxml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.python.org/packages/source/e/et_xmlfile/et_xmlfile-${pkgver}.tar.gz"
        "LICENSE")
sha256sums=('dab3f4764309081ce75662649be815c4c9081e88f0837825f90fd28317d4da54'
            '69a810ce7342b9198bd2e44d0098e30b4ce31078019e6cf990a5cd6ce2c3f7ce')

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 -Dm644 "${srcdir}"/LICENSE "${pkgdir}"${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
