# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>

_pyname=jupyter_core
pkgname=python-${_pyname/_/-}
pkgver=5.9.1
pkgrel=1
pkgdesc='Jupyter core package. A base package on which Jupyter projects rely'
arch=(any)
url='https://pypi.python.org/pypi/jupyter_core'
license=(BSD-3-Clause)
depends=(python
         python-argcomplete
         python-traitlets
         python-platformdirs)
makedepends=(git
             python-build
             python-hatchling
             python-installer)
checkdepends=(python-pip
              python-pytest)
conflicts=(python-jupyter_core)
provides=(python-jupyter_core)
replaces=(python-jupyter_core)
source=(git+https://github.com/jupyter/jupyter_core#tag=v$pkgver)
sha256sums=('9e9e35096c8954817231766ffd071f0ecf749c932b78f5a9d933f52da95d10c2')

prepare() {
  cd $_pyname
  sed -e '/\/usr\/local\/share\/jupyter/d' -i jupyter_core/paths.py
}

build() {
  cd $_pyname
  python -m build -wn
}

check() {
  cd $_pyname
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest -v -W ignore::ResourceWarning
}

package() {
  cd $_pyname
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
  install -Dm644 examples/jupyter-completion.bash "$pkgdir"/usr/share/bash-completion/completions/jupyter
  install -Dm644 examples/completions-zsh "$pkgdir"/usr/share/zsh/site-functions/_jupyter
}
