# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Igor Scabini <furester @ gmail.com>

pkgname=cython
pkgver=3.0.11
pkgrel=1
pkgdesc='C-Extensions for Python'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='https://cython.org'
license=(Apache-2.0)
depends=(glibc
         python)
replaces=(cython-dev)
makedepends=(git
             python-build
             python-installer
             python-setuptools
             python-wheel)
checkdepends=(gdb
              python-numpy
              python-pytest
              python-tests)
source=(git+https://github.com/cython/cython#tag=$pkgver
        numpy-2.patch)
sha256sums=('8f6bc386d85aaf9bbab8174bc3f8c771204b0bedacd6e7502261a5fdcc4d9c75'
            '6f98a6cc46d0d65a01a1fb5ac9f40e6d2612f80a34ad8e95bd9ad1116e24855d')

prepare() {
  cd cython
  patch -p1 -i ../numpy-2.patch # Fix tests with numpy 2
}

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

check() {
  cd cython
  python runtests.py -vv -j 64 --no-pyregr
}

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

  for f in cygdb cython cythonize; do
    mv "$pkgdir"/usr/bin/$f "$pkgdir"/usr/bin/${f}3
    ln -s ${f}3 "$pkgdir"/usr/bin/$f
  done
}
