# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=jupyter_server
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.17.0
pkgrel=1
pkgdesc='Provides backend for core services, APIs and REST endpoints to Jupyter web application (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: jupyter-server'
  'purl: pkg:pypi/jupyter-server'
  "cpe: cpe:/a:jupyter:jupyter_server"
)
url='https://jupyter-server.readthedocs.io/'
msys2_repository_url='https://github.com/jupyter-server/jupyter_server/'
msys2_changelog_url='https://github.com/jupyter-server/jupyter_server/blob/main/CHANGELOG.md'
license=('spdx:BSD-3-Clause')
options=('!strip')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-anyio
    ${MINGW_PACKAGE_PREFIX}-python-argon2_cffi
    ${MINGW_PACKAGE_PREFIX}-python-jinja
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_client
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_core
    ${MINGW_PACKAGE_PREFIX}-python-jupyter-server-terminals
    ${MINGW_PACKAGE_PREFIX}-python-jupyter-nbconvert
    ${MINGW_PACKAGE_PREFIX}-python-jupyter-nbformat
    ${MINGW_PACKAGE_PREFIX}-python-packaging
    ${MINGW_PACKAGE_PREFIX}-python-prometheus-client
    ${MINGW_PACKAGE_PREFIX}-python-pywinpty
    ${MINGW_PACKAGE_PREFIX}-python-pyzmq
    ${MINGW_PACKAGE_PREFIX}-python-send2trash
    ${MINGW_PACKAGE_PREFIX}-python-terminado
    ${MINGW_PACKAGE_PREFIX}-python-tornado
    ${MINGW_PACKAGE_PREFIX}-python-overrides
    ${MINGW_PACKAGE_PREFIX}-python-traitlets
    ${MINGW_PACKAGE_PREFIX}-python-websocket-client
    ${MINGW_PACKAGE_PREFIX}-python-jupyter-events)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-build
    ${MINGW_PACKAGE_PREFIX}-python-installer
    ${MINGW_PACKAGE_PREFIX}-python-hatchling
    ${MINGW_PACKAGE_PREFIX}-python-hatch-jupyter-builder)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/_/-}/${_realname}-${pkgver}.tar.gz")
sha256sums=('c38ea898566964c888b4772ae1ed58eca84592e88251d2cfc4d171f81f7e99d5')

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