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

_realname=dnspython
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.8.0
pkgrel=1
pkgdesc="A DNS toolkit for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.dnspython.org/'
msys2_repository_url="https://github.com/rthalley/dnspython"
msys2_changelog_url='https://dnspython.readthedocs.io/en/stable/whatsnew.html'
msys2_references=(
  'anitya: 13190'
  'archlinux: python-dnspython'
  'gentoo: dev-python/dnspython'
  'purl: pkg:pypi/dnspython'
)
license=('spdx:ISC')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
)
optdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-cryptography: DNSSEC support"
  "${MINGW_PACKAGE_PREFIX}-python-requests-toolbelt: DoH support"
  "${MINGW_PACKAGE_PREFIX}-python-idna: support for updated IDNA 2008"
  #"${MINGW_PACKAGE_PREFIX}-python-curio: async support"
  #"${MINGW_PACKAGE_PREFIX}-python-trio: async support"
  #"${MINGW_PACKAGE_PREFIX}-python-sniffio: async support"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-hatchling"
)
checkdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-idna"
  "${MINGW_PACKAGE_PREFIX}-python-cryptography"
  #"${MINGW_PACKAGE_PREFIX}-python-trio"
  "${MINGW_PACKAGE_PREFIX}-python-pytest"
)
source=(https://pypi.io/packages/source/${_realname:0:1}/${_realname}/${_realname}-${pkgver}.tar.gz)
sha256sums=('181d3c6996452cb1189c4046c61599b84a5a86e099562ffde77d26984ff26d0f')

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

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
    cd "${_realname}-${pkgver}"

    pytest
}

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