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

pkgname=python-sphinxcontrib-htmlhelp
_name=${pkgname#python-}
pkgver=2.1.0
pkgrel=3
pkgdesc='Sphinx extension which renders HTML help files'
arch=(any)
url=https://github.com/sphinx-doc/sphinxcontrib-htmlhelp
license=(BSD-2-Clause)
depends=(python)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
)
checkdepends=(
  python-html5lib
  python-pytest
  python-sphinx
)
source=("git+$url.git#tag=$pkgver")
b2sums=('219ea3c0fa4884e17af74fad70cf5a6c303a93684101fbd3216c1d07801887ed087add45c93223330eb27da5cf3a9ec659fee72b6e83bb2ce0789cc9c6cc33ed')

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

check() {
  cd "$_name"
  pytest
}

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
}
