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

pkgname=python-ipython-pygments-lexers
_name=${pkgname#python-}
pkgver=1.1.1
pkgrel=1
pkgdesc='Defines a variety of Pygments lexers for highlighting IPython code'
arch=(any)
url=https://github.com/ipython/ipython-pygments-lexers
license=('BSD-3-Clause')
depends=(python-pygments)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
)
checkdepends=(
  ipython
  python-pytest
)
source=("git+$url.git#tag=$pkgver")
b2sums=('212e91dbe6ad3d2c5df5d4982a0794515bea4b0fef358de8cf1c2bd15ad350b1e23c709a03bfdcc78b85ea5cfa9b5006842ad165b92dc8fb81d4f826ee3eff4a')

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

check() {
  cd "$_name"
  pytest
}

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/LICENSE

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