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

_realname=gmpy2
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.2.2
pkgrel=1
pkgdesc="Provides C-coded Python modules for fast multiple-precision arithmetic (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-gmpy2'
  'purl: pkg:pypi/gmpy2'
)
msys2_repository_url='https://github.com/gmpy2/gmpy2'
url='https://gmpy2.readthedocs.io/'
license=('spdx:LGPL-3.0-or-later OR GPL-3.0-or-later')
depends=(
  "${MINGW_PACKAGE_PREFIX}-gmp"
  "${MINGW_PACKAGE_PREFIX}-mpc"
  "${MINGW_PACKAGE_PREFIX}-mpfr"
  "${MINGW_PACKAGE_PREFIX}-python"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('d9b8c81e0f5e1a3cabf1ea8d154b29b5ef6e33b8f4e4c37b3da957b2dd6a3fa8')

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 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
  install -Dm644 COPYING.LESSER "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING.LESSER"
}
