# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=trustme
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.2.1
pkgrel=1
pkgdesc='Library for fake certificate authority (CA) to generate fake TLS certs (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/trustme'
)
url="https://github.com/python-trio/trustme"
license=('spdx:MIT OR spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-cryptography"
         "${MINGW_PACKAGE_PREFIX}-python-idna")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pyopenssl"
              "${MINGW_PACKAGE_PREFIX}-python-service-identity")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('6528ba2bbc7f2db41f33825c8dd13e3e3eb9d334ba0f909713c8c3139f4ae47f')

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 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
  install -Dm644 LICENSE.APACHE2 "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.APACHE2"
  install -Dm644 LICENSE.MIT "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.MIT"
  install -Dm 644 README.rst -t "${pkgdir}${MINGW_PREFIX}/share/doc/python-${_realname}"
}
