# Maintainer: Frederic Wang <fred.wang@free.fr>

_realname=pyasn1-modules
_pyname=pyasn1_modules
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.4.2
pkgrel=1
pkgdesc='A collection of ASN.1-based protocols modules (mingw-w64)'
msys2_references=(
  'archlinux: python-pyasn1-modules'
  'purl: pkg:pypi/pyasn1-modules'
)
msys2_repository_url='https://github.com/pyasn1/pyasn1-modules/'
url='https://pyasn1.readthedocs.io/'
license=('spdx:BSD-2-Clause')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-python-pyasn1")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('677091de870a80aae844b1ca6134f54652fa2c8c5a52aa396440ac3106e941e6')

build() {
  cp -r "${_pyname}-${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 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
