# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Juergen Hoetzel <juergen@archlinux.org>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>

pkgname=python-twisted
pkgver=24.3.0
pkgrel=4
pkgdesc="Asynchronous networking framework written in Python"
arch=(any)
url="https://twistedmatrix.com/"
license=('MIT')
depends=(
  'python'
  'python-attrs'
  'python-automat'
  'python-constantly'
  'python-hyperlink'
  'python-incremental'
  'python-typing_extensions'
  'python-zope-interface'
)
makedepends=(
  'python-build'
  'python-hatch-fancy-pypi-readme'
  'python-hatchling'
  'python-installer'
  'python-wheel'
)
optdepends=(
  'gobject-introspection-runtime: for GObject Introspection support'
  'python-appdirs: for using conch'
  'python-bcrypt: for using conch'
  'python-cryptography: for using conch'
  'python-h2: for http2 support'
  'python-idna: for TLS client hostname verification'
  'python-priority: for http2 support'
  'python-pyasn1: for using conch'
  'python-gobject: for GObject Introspection support'
  'python-pyopenssl: for TLS client hostname verification'
  'python-pyserial: for serial support'
  'python-service-identity: for TLS client hostname verification'
  'tk: for using tkconch'
)
checkdepends=(
  'cairo'
  'git'
  'glib2'
  'gtk3'
  'libffi'
  'libgirepository'
  'openssh'
  'python-bcrypt'
  'python-cryptography'
  'python-cython-test-exception-raiser'
  'python-gobject'
  'python-h2'
  'python-hypothesis'
  'python-idna'
  'python-priority'
  'python-pyasn1'
  'python-pyhamcrest'
  'python-pyopenssl'
  'python-pyserial'
  'python-service-identity'
  'python-subunit'
  'subversion'
  'tk'
  'xorg-server-xvfb'
)
source=("https://github.com/twisted/twisted/archive/twisted-$pkgver.tar.gz")
sha512sums=('e6c787b8b7a01cb0e30569706f1ecc216eee92cb9d0414e92d9e7fc888a6ffa89516a1f585e0034b2756bcf3d7f9ffafb9d6c11952615da9555bbfaa7d7cfc83')

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

check() {
  export LC_CTYPE=en_US.UTF-8

  # tests use the underlying function from the 'python -m twisted.trial' module, to prevent loading system entry points
  PYTHONPATH="$srcdir/twisted-twisted-$pkgver/src" xvfb-run python -c 'from twisted.scripts.trial import run; run()' twisted || echo "Tests failed"
}

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