# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgname=python-sphinxcontrib-trio
_pyname=${pkgname/python-/}
pkgver=1.1.2
pkgrel=7
pkgdesc='Make Sphinx better at documenting Python functions and methods'
url='https://github.com/python-trio/sphinxcontrib-trio'
arch=('any')
license=('MIT')
depends=('python' 'python-sphinx')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest' 'python-lxml' 'python-cssselect')
source=(https://github.com/python-trio/sphinxcontrib-trio/archive/v${pkgver}/${_pyname}-${pkgver}.tar.gz)
sha512sums=('490511ce953e0589759af7fd98dbfe1e9875c9bf3ca0046491fd0cbf25cec37fe5c343a4eacce5e9db3e9e0aca23a9ab7993fb19dd77b7bf95cc38e7ff2911ff')

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

check() {
  cd ${_pyname}-${pkgver}
  # https://github.com/python-trio/sphinxcontrib-trio/issues/260
  PYTHONPATH=. py.test -k 'not test_end_to_end'
}

package() {
  cd ${_pyname}-${pkgver}
  python -m installer --destdir="${pkgdir}" dist/*.whl
  install -Dm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"

  # 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}/${_pyname//-/_}-${pkgver}.dist-info/LICENSE" \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
