# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Omar Sandoval <osandov at cs dot washington dot edu>
# Contributor: Alexander Slesarev <slesarew at gmail dot com>

pkgname=python-gmpy2
pkgver=2.1.5
pkgrel=3
pkgdesc='Provides C-coded Python modules for fast multiple-precision arithmetic'
arch=(x86_64 aarch64)
url='https://github.com/aleaxit/gmpy'
license=(LGPL2.1)
depends=(libmpc
         python)
makedepends=(python-build
             python-installer
             python-setuptools
             python-wheel)
source=(https://github.com/aleaxit/gmpy/archive/refs/tags/gmpy2-$pkgver.tar.gz
        python-3.12.patch)
sha256sums=('ae9e4e0fa305b2693d7d32698b49426907724ffde31b01330a4051a8f5388e37'
            '6b0994285919e373d2e91b3e0662c7775f03a194a116b5170fdc41837dd3551e')

prepare() {
  patch -d gmpy-gmpy2-$pkgver -p1 < python-3.12.patch
}

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

package() {
  cd gmpy-gmpy2-$pkgver 
  python -m installer --destdir="$pkgdir" dist/*.whl
 
  install -d -m 755 $pkgdir/usr/share/doc/$pkgname
  install -m 644 -t $pkgdir/usr/share/doc/$pkgname docs/*
}
