# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=tomli
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.3.0
pkgrel=1
pkgdesc="A lil' TOML parser (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/hukkin/tomli'
msys2_changelog_url='https://github.com/hukkin/tomli/blob/master/CHANGELOG.md'
msys2_references=(
  'archlinux: python-tomli'
  'gentoo: dev-python/tomli'
  'purl: pkg:pypi/tomli'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-flit-core")
source=("$url/archive/$pkgver/${_realname}-$pkgver.tar.gz")
sha256sums=('438851e2e43c7b5c43f211bd40fefdf9e59eb733477dc48525e61de09eb33339')

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

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

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

  python -m unittest
}

package() {
  cd "${srcdir}/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"
}
