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

pkgname=python-sphinxcontrib-applehelp
_name=${pkgname#python-}
pkgver=2.0.0
pkgrel=3
pkgdesc='Sphinx extension which outputs Apple help books'
arch=(any)
url=https://github.com/sphinx-doc/sphinxcontrib-applehelp
license=(BSD-2-Clause)
depends=(python)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
)
checkdepends=(
  python-pytest
  python-sphinx
)
source=("git+$url.git#tag=$pkgver")
b2sums=('152bb60660b0b3ed301e818c617c05fa23c3fae888aeae4eeb3ba1cad0fddeafda1658c55c10ddbad5530f5fc9c6cb0a6349b8e4ac484899876af7b926eb8f95')

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
}
