# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=jupyterlab-widgets
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0.16
pkgrel=2
pkgdesc="JupyterLab extension to use ipywidgets (mingw-w64)"
url="https://github.com/jupyter-widgets/ipywidgets"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/jupyterlab-widgets'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python-jupyterlab"
         "${MINGW_PACKAGE_PREFIX}-python-ipywidgets")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-jupyter-builder"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('423da05071d55cf27a9e602216d35a3a65a3e41cdf9c5d3b643b814ce38c19e0')

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=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
