# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-pyaml
pkgver=24.12.0
pkgrel=1
pkgdesc="PyYAML-based module to produce pretty and readable YAML-serialized data"
url="https://github.com/mk-fg/pretty-yaml"
license=('WTFPL')
arch=('any')
depends=('python-yaml')
makedepends=('git' 'python-setuptools' 'python-build' 'python-installer' 'python-wheel')
checkdepends=('python-unidecode')
optdepends=('python-unidecode: Needed if same-id objects or recursion is used within serialized data')
source=("git+https://github.com/mk-fg/pretty-yaml.git#tag=$pkgver")
sha512sums=('8766ecffd12219587ee202ff64379d67a98c060c8d309bed4cfc4e134d79565e2f06dafb87072ae49ad2eb66eea09e90ea8d20437aa57ac21b12d97cf7839d5e')

build() {
  cd pretty-yaml
  python -m build --wheel --no-isolation
}

check() {
  cd pretty-yaml
  python -m unittest -v
}

package() {
  cd pretty-yaml
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/

  # Remove tests
  python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  rm -r "$pkgdir"/usr/lib/python"$python_version"/site-packages/pyaml/tests
}
