# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Sébastien Luttringer
# Contributor : Ionut Biru <ibiru@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=python-docutils
_name=${pkgname#python-}
pkgver=0.22.3
pkgrel=1
epoch=1
pkgdesc='Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX'
arch=('any')
url='http://docutils.sourceforge.net'
license=(
  'LicenseRef-Public-Domain'
  'BSD-2-Clause'
)
depends=('python')
makedepends=(
  'python-build'
  'python-flit-core'
  'python-installer'
)
checkdepends=('python-pillow')
optdepends=(
  'python-myst-parser: to parse input in "Markdown" (CommonMark) format'
  'python-pillow: for some image manipulation operations'
  'python-pygments: for syntax highlighting of code directives and roles'
)
source=("https://downloads.sourceforge.net/$_name/$_name-$pkgver.tar.gz")
b2sums=('78b4ee1dd643de2b1e97757592ca2962eb11beb7beb2cf6c718857b1533a55240c44993e840b720eb4cfa327cafa6a9b1ebdea46eac2f0f6a3f9d06d1eb4851a')

prepare() {
  cd "$_name"-$pkgver
  # Remove include list https://github.com/pypa/wheel/issues/92
  sed -i '/^include =/,/]/d' pyproject.toml
}

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

check() {
  cd "$_name"-$pkgver/test
  python alltests.py
}

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/{COPYING,licenses/BSD-2-Clause}.rst \
    "$pkgdir"/usr/share/licenses/$pkgname

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

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