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

pkgname=python-matplotlib-inline
_name=${pkgname#python-}
pkgver=0.1.7
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-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('ipython' 'python-matplotlib')
optdepends=('python-matplotlib')
source=("git+$url.git#tag=$pkgver")
b2sums=('29a3742892040b2529234d7cd68f35b80ff240e83d7aee858a1447547e707dd405e32b887ec05e139eae1eba13a10a23e089a517659579c3f83eabc733f78d8a')

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 -c 'from matplotlib_inline.backend_inline import show'
}

package() {
  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  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/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

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