# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=python-eventlet
pkgver=0.40.4
pkgrel=2
pkgdesc='Highly concurrent networking library'
url='https://eventlet.net'
arch=('any')
license=('MIT')
depends=(
  'python'
  'python-dnspython'
  'python-greenlet'
)
makedepends=(
  'python-build'
  'python-hatch-vcs'
  'python-hatchling'
  'python-installer'
  'python-sphinx'
  'python-sphinxcontrib-apidoc'
)
checkdepends=(
  'python-httplib2'
  'python-psycopg2'
  'python-pyopenssl'
  'python-pytest'
  'python-pyzmq'
)
optdepends=(
  'python-httplib2: non-blocking HTTP support'
  'python-psycopg2: non-blocking PostgreSQL support'
  'python-pyopenssl: non-blocking SSL support'
  'python-pyzmq: non-blocking ZeroMQ support'
)
source=("https://github.com/eventlet/eventlet/archive/$pkgver/${pkgname#python-}-$pkgver.tar.gz")
sha512sums=('398a7e9a616e215709556e5f897bb3aa0b94116dfa3a5de7297d4208af20ae0922874c2e5076f7671b2f720d9177c548abef4af7f3b1752b997ae77c97ad72c7')
b2sums=('90e31ecbc8f39883c596cd9a77bbe174cbd87a51126252fbd8548f97756a6d379da192054be89a8396879584deee3b14712e1ac6afca7b7d5762d87643fa3ce7')

build() {
  cd ${pkgname#python-}-$pkgver
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
  python -m build --wheel --no-isolation

  python -m venv --system-site-packages doc-env
  doc-env/bin/python -m installer dist/*.whl
  local site_packages=$(doc-env/bin/python -c "import site; print(site.getsitepackages()[0])")
  PYTHONPATH="$site_packages" sphinx-build -b text doc/source doc/build/html
}

check() {
  cd ${pkgname#python-}-$pkgver
  # test_ssl_close already failed under Python3.12 "known regression"
  pytest tests --deselect=tests/ssl_test.py::SSLTest::test_ssl_close 
}

package() {
  cd ${pkgname#python-}-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  install -vdm 755 "$pkgdir/usr/share/doc/$pkgname"
  cp -vr doc/build/html "$pkgdir/usr/share/doc/$pkgname"
  cp -vr examples "$pkgdir/usr/share/doc/$pkgname"
}

# vim: ts=2 sw=2 et:
