pkgname=pyyaml
pkgver=6.0.3
pkgdesc='Python bindings for YAML, using fast libYAML library'
arch=(x86_64)
homepage='https://github.com/yaml/pyyaml'
license=(MIT)
depends=(
  glibc
  libyaml
  python
)
makedepends=(
  cython
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-pytest
)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://files.pythonhosted.org/packages/source/${pkgname:0:1}/${pkgname}/${sources[0]}")
md5sums=("dbc6f815cd75160ccf12e470be1c8d6e")

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

src_build() {
  python -m build --wheel --no-isolation --config-setting=--with-libyaml
}

src_check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  PYTHONPATH="$PWD/test_dir/$site_packages:$PYTHONPATH" pytest "${pytest_options[@]}"
}

src_install() {
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
  install -Dm 644 CHANGES README.md -t "$pkgdir"/usr/share/doc/$pkgname/
}

# vim:ft=sh syn=sh et sw=2:
