# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=jupyter-events
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.12.0
pkgrel=1
pkgdesc="Jupyter Event System library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://jupyter-events.readthedocs.io/'
msys2_repository_url='https://github.com/jupyter/jupyter_events'
msys2_references=(
  'archlinux: python-jupyter-events'
  'purl: pkg:pypi/jupyter-events'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-click"
         "${MINGW_PACKAGE_PREFIX}-python-jsonschema"
         "${MINGW_PACKAGE_PREFIX}-python-json-logger"
         "${MINGW_PACKAGE_PREFIX}-python-referencing"
         "${MINGW_PACKAGE_PREFIX}-python-rfc3339-validator"
         "${MINGW_PACKAGE_PREFIX}-python-rfc3986-validator"
         "${MINGW_PACKAGE_PREFIX}-python-rich"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-traitlets"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('fc3fce98865f6784c9cd0a56a20644fc6098f21c8c33834a8d9fe383c17e554b')

build() {
  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 "${srcdir}/python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m pytest || warning "Tests failed"
}

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"
}
