# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Samuel Littley <aur@toastwaffle.com>
# Contributor: rnons <remotenonsense at gmail dot com>

_pkg=ruamel.yaml.clib
pkgname=python-$_pkg
pkgver=0.2.12
pkgrel=3
pkgdesc="C version of reader, parser and emitter for ruamel.yaml derived from libyaml"
arch=('x86_64' 'aarch64')
url="https://sourceforge.net/projects/ruamel-yaml-clib/"
license=('MIT')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
source=(https://files.pythonhosted.org/packages/source/r/${_pkg}/${_pkg}-${pkgver}.tar.gz)
sha512sums=('36715cfaa663f9948034d7eb64f1b9e9cf69971e27e5ac1f2cd54234c8889c91416fe95aa3f5cce44eb00c9c383f458457c3f5ba9e3afa3e5637c118ec2e5113')

build() {
  cd ${_pkg}-${pkgver}
  # Workaround for GCC 14, see https://sourceforge.net/p/ruamel-yaml-clib/tickets/22/
  CFLAGS="$CFLAGS -Wno-error=incompatible-pointer-types" \
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd ${_pkg}-${pkgver}
  python -m installer --destdir="${pkgdir}" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "${pkgdir}"/usr/share/licenses/"${pkgname}"
  ln -s "${site_packages}"/${_pkg}-${pkgver}.dist-info/LICENSE \
    "${pkgdir}"/usr/share/licenses/"${pkgname}"/LICENSE
}
