# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Marcin "avalan" Falkiewicz <avalatron@gmail.com>
# Contributor: C Anthony Risinger <anthony@xtfx.me>

pkgname=python-ply
pkgver=3.11
pkgrel=17
pkgdesc='Implementation of lex and yacc parsing tools'
arch=('any')
url='https://www.dabeaz.com/ply/'
license=('BSD-3-Clause')
depends=('python')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
source=("git+https://github.com/dabeaz/ply.git#tag=$pkgver"
        python-3.11.patch
        license-from-upstream)
sha512sums=('9f96e8ee99908003633f198f155893652b508dbfb3f5d063eab087839a3a0d66ef8341037df5236a13a2161cb3800b8b16400505ef03e3cfe21b5d51b28ece1c'
            '7f55edd7b78abdd786e4a7b46deb912878d272cf63029ceff285d9387f14c364aa0c9ff1b53d8d60df377e848d5f9272c814948478d6a39f543dac4cca3bc270'
            '5cea085a23ed260afc9084380c1d59e3942c2385089a8eb2391a89c85cde4df2ceb7eed21bb8c4d0cad5b78e59742da69e4c5c78fd0e223f5c99c56e9296a075')

prepare() {
  patch -d ply -p1 < python-3.11.patch # Fix tests with python 3.11 (Fedora)
}

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

check() {
  cd "ply/test"
  python testlex.py
  python testyacc.py
}

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

  install -Dm644 ../license-from-upstream "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:
