# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Ralf Schmitt <ralf@systemexit.de>

pkgname=python-gevent
pkgver=26.5.0
pkgrel=1
pkgdesc='Python network library that uses greenlet and libenv for easy and scalable concurrency'
arch=(x86_64 aarch64)
url='http://www.gevent.org'
license=(MIT)
depends=(
  glibc
  c-ares
  libev
  libuv
  python-greenlet
  python-setuptools
  python-zope-event
  python-zope-interface
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
  cython
  python-cffi
)
checkdepends=(
  lsof
  python-perf
  python-objgraph
  python-dnspython
  python-requests
)
source=("$pkgname::git+https://github.com/gevent/gevent#tag=$pkgver")
sha512sums=('fce672ba27aef6d30615f9033e36a51f55451127f2211f31d7b36c274f85f41d91562db4d35e487aa248d7905718912265d014b0301c6ae010f57444182fe61e')
b2sums=('20ab30b2efdaeafcf918aeb9b4adee1e03cd7710bf616ff4061b20733161d59d44bce672f01e98179596145d0a8cc8226a05d9117cd89df244da5bfafcebc7f6')

build() {
  cd "$pkgname"

  # http://www.gevent.org/development/installing_from_source.html#embedding-libraries
  export GEVENTSETUP_EMBED=0

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m gevent.tests || echo "Tests failed"
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
