pkgname=docutils
pkgver=0.21.2
pkgdesc='Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX'
arch=('any')
homepage='http://docutils.sourceforge.net'
license=(
  'LicenseRef-Public-Domain'
  'BSD-2-Clause'
)
sources=("${pkgname/-/_}-${pkgver}.tar.gz")
urls=("https://files.pythonhosted.org/packages/source/${pkgname:0:1}/${pkgname}/${sources[0]}")
md5sums=("c4064e1e0e3cd142951fd2b95b830874")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  python -m build --wheel --no-isolation --skip-dependency-check
}

# check need pillow

src_install() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/"$pkgname"-$pkgver.dist-info/licenses/COPYING.txt \
    "$pkgdir"/usr/share/licenses/$pkgname

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