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

_realname=jupyterlab
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=4.5.1
pkgrel=2
pkgdesc='JupyterLab computational environment (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://jupyterlab.readthedocs.io/'
msys2_repository_url='https://github.com/jupyterlab/jupyterlab/'
msys2_references=(
  'archlinux: jupyterlab'
  'purl: pkg:pypi/jupyterlab'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-async-lru"
         "${MINGW_PACKAGE_PREFIX}-python-ipykernel"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_core"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter-lsp"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_server"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_notebook_shim"
         "${MINGW_PACKAGE_PREFIX}-python-jupyterlab-server"
         "${MINGW_PACKAGE_PREFIX}-python-httpx"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-traitlets"
         "${MINGW_PACKAGE_PREFIX}-python-tornado"
)
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-jupyter-builder"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('09da1ddfbd9eec18b5101dbb8515612aa1e47443321fb99503725a88e93d20d9')

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
}
