# Maintainer: Patrick Stewart <patstew@gmail.com>
# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=jupyter_client
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=8.7.0
pkgrel=2
pkgdesc="The reference implementation of the Jupyter protocol (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-jupyter-client'
  'purl: pkg:pypi/jupyter-client'
)
url="https://jupyter-client.readthedocs.io/"
msys2_repository_url="https://github.com/jupyter/jupyter_client/"
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-dateutil"
         "${MINGW_PACKAGE_PREFIX}-python-entrypoints"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_core"
         "${MINGW_PACKAGE_PREFIX}-python-nest-asyncio"
         "${MINGW_PACKAGE_PREFIX}-python-pyzmq"
         "${MINGW_PACKAGE_PREFIX}-python-tornado"
         "${MINGW_PACKAGE_PREFIX}-python-traitlets")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('3357212d9cbe01209e59190f67a3a7e1f387a4f4e88d1e0433ad84d7b262531d')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/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"
}
