# Template file for 'python3-Twisted'
pkgname=python3-Twisted
version=24.11.0
revision=1
build_style=python3-pep517
hostmakedepends="hatchling hatch-fancy-pypi-readme python3-incremental
 python3-setuptools"
makedepends="python3-devel"
depends="python3-zope.interface python3-constantly python3-incremental
 python3-automat python3-hyperlink python3-attrs python3-typing_extensions
 python3-openssl python3-service_identity python3-idna"
checkdepends="python3-PyHamcrest python3-hypothesis python3-pyserial
 python3-cryptography python3-appdirs python3-bcrypt python3-h2
 python3-priority git xvfb-run python3-httpx $depends"
short_desc="Asynchronous networking framework written in Python (Python3)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://twisted.org/"
changelog="https://raw.githubusercontent.com/twisted/twisted/trunk/NEWS.rst"
distfiles="${PYPI_SITE}/t/twisted/twisted-${version}.tar.gz"
checksum=695d0556d5ec579dcc464d2856b634880ed1319f45b10d19043f2b57eb0115b5

alternatives="
 twisted:cftp:/usr/bin/cftp3
 twisted:ckeygen:/usr/bin/ckeygen3
 twisted:conch:/usr/bin/conch3
 twisted:mailmail:/usr/bin/mailmail3
 twisted:pyhtmlizer:/usr/bin/pyhtmlizer3
 twisted:tkconch:/usr/bin/tkconch3
 twisted:trial:/usr/bin/trial3
 twisted:twist:/usr/bin/twist3
 twisted:twistd:/usr/bin/twistd3"

post_patch() {
	# test requires unpackaged cython-test-exception-raiser
	rm src/twisted/test/test_failure.py
	# issues with executing shell executables from the test
	rm src/twisted/test/test_main.py
}

do_check() {
	export LC_CTYPE=en_US.UTF-8
	testdir="${wrksrc}/.xbps-testdir/$(date +%s)"
	python3 -m installer --destdir "${testdir}" \
		${make_install_args} ${make_install_target:-dist/*.whl}
	PATH="${testdir}/usr/bin:${PATH}" PYTHONPATH="${testdir}/${py3_sitelib}" \
		trial ${makejobs} src/twisted
}

post_install() {
	# don't conflict with python-Twisted
	for f in "${DESTDIR}"/usr/bin/*; do
		mv "${f}"{,3}
	done

	vlicense LICENSE
}
