# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-pyaml
pkgver=24.7.0
pkgrel=1
pkgdesc="PyYAML-based module to produce pretty and readable YAML-serialized data"
url="https://pypi.python.org/pypi/pyaml"
license=('WTFPL')
arch=(any)
depends=('python-yaml')
makedepends=('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=("https://pypi.io/packages/source/p/pyaml/pyaml-$pkgver.tar.gz")
sha512sums=('c5ce15f0264e8783ed6e03348ad74d25708129fbd377e2ec0fd0c6de72e763ff3cf79ba5d6cc4b641f0422ab87f8103538f2ba6abb16ea21e6820259f4a48b29')

build() {
  cd pyaml-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd pyaml-$pkgver
  python -m unittest -v
}

package() {
  cd pyaml-$pkgver
  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
}
