# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgname=python-matplotlib-inline
_name=${pkgname#python-}
pkgver=0.2.1
pkgrel=1
pkgdesc='Inline Matplotlib backend for Jupyter'
arch=(any)
url=https://github.com/ipython/matplotlib-inline
license=(BSD-3-Clause)
depends=(python-traitlets)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
)
checkdepends=(
  ipython
  jupyter-notebook
  python-matplotlib
  python-nbval
  python-pytest
)
optdepends=(python-matplotlib)
source=("git+$url.git#tag=$pkgver")
b2sums=('d6dbf0e51f86a468823f1e282b27ecde6c2442105869ae55abe4b374716e63275bcd998cc12f2062ce9bef140a413e08a19176d37e136e88b5a3d6e3f0ac9c27')

build() {
  cd "$_name"
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "$_name"
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest -v
}

package() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/"${_name//-/_}"-$pkgver.dist-info/licenses/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname

  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl
}

# vim:set ts=2 sw=2 et:
