summaryrefslogtreecommitdiff
path: root/dev-python/twisted
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2025-09-29 11:22:15 +0200
committerMichał Górny <mgorny@gentoo.org>2025-09-29 11:22:15 +0200
commit2ea58dfa44a656b1ee2d09a5992d902de1e9d9dd (patch)
treee1ea2c06ddcacda1e32b47f81edf8961979637c5 /dev-python/twisted
parenta30d924b7708495306ce9fee39e944e2e78e27d5 (diff)
downloadgentoo-2ea58dfa44a656b1ee2d09a5992d902de1e9d9dd.tar.gz
gentoo-2ea58dfa44a656b1ee2d09a5992d902de1e9d9dd.tar.bz2
gentoo-2ea58dfa44a656b1ee2d09a5992d902de1e9d9dd.zip
dev-python/twisted: Backport a partial py3.14 fix
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/twisted')
-rw-r--r--dev-python/twisted/files/twisted-25.5.0-py314.patch26
-rw-r--r--dev-python/twisted/twisted-25.5.0-r1.ebuild171
2 files changed, 197 insertions, 0 deletions
diff --git a/dev-python/twisted/files/twisted-25.5.0-py314.patch b/dev-python/twisted/files/twisted-25.5.0-py314.patch
new file mode 100644
index 000000000000..88bb87360bcb
--- /dev/null
+++ b/dev-python/twisted/files/twisted-25.5.0-py314.patch
@@ -0,0 +1,26 @@
+diff --git a/src/twisted/internet/asyncioreactor.py b/src/twisted/internet/asyncioreactor.py
+index cd1cf65f05d..03b2d8ecb24 100644
+--- a/src/twisted/internet/asyncioreactor.py
++++ b/src/twisted/internet/asyncioreactor.py
+@@ -9,7 +9,7 @@
+
+ import errno
+ import sys
+-from asyncio import AbstractEventLoop, get_event_loop
++from asyncio import AbstractEventLoop, get_running_loop, new_event_loop, set_event_loop
+ from typing import Dict, Optional, Type
+
+ from zope.interface import implementer
+@@ -47,7 +47,11 @@ class AsyncioSelectorReactor(PosixReactorBase):
+
+ def __init__(self, eventloop: Optional[AbstractEventLoop] = None):
+ if eventloop is None:
+- _eventloop: AbstractEventLoop = get_event_loop()
++ try:
++ _eventloop: AbstractEventLoop = get_running_loop()
++ except RuntimeError:
++ _eventloop = new_event_loop()
++ set_event_loop(_eventloop)
+ else:
+ _eventloop = eventloop
+
diff --git a/dev-python/twisted/twisted-25.5.0-r1.ebuild b/dev-python/twisted/twisted-25.5.0-r1.ebuild
new file mode 100644
index 000000000000..2ebc6266427b
--- /dev/null
+++ b/dev-python/twisted/twisted-25.5.0-r1.ebuild
@@ -0,0 +1,171 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=hatchling
+PYTHON_TESTED=( python3_{11..14} pypy3_11 )
+PYTHON_COMPAT=( "${PYTHON_TESTED[@]}" )
+PYTHON_REQ_USE="threads(+)"
+
+inherit distutils-r1 multiprocessing pypi virtualx
+
+DESCRIPTION="An asynchronous networking framework written in Python"
+HOMEPAGE="
+ https://twisted.org/
+ https://github.com/twisted/twisted/
+ https://pypi.org/project/Twisted/
+"
+SRC_URI+="
+ https://dev.gentoo.org/~mgorny/dist/twisted-regen-cache.gz
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos"
+IUSE="conch http2 serial ssl test websockets"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+ >=dev-python/attrs-22.2.0[${PYTHON_USEDEP}]
+ >=dev-python/automat-24.8.0[${PYTHON_USEDEP}]
+ >=dev-python/constantly-15.1[${PYTHON_USEDEP}]
+ >=dev-python/hyperlink-17.1.1[${PYTHON_USEDEP}]
+ >=dev-python/incremental-22.10.0[${PYTHON_USEDEP}]
+ >=dev-python/typing-extensions-4.2.0[${PYTHON_USEDEP}]
+ >=dev-python/zope-interface-5[${PYTHON_USEDEP}]
+ conch? (
+ >=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
+ >=dev-python/bcrypt-3.0.0[${PYTHON_USEDEP}]
+ >=dev-python/cryptography-3.3[${PYTHON_USEDEP}]
+ dev-python/pyasn1[${PYTHON_USEDEP}]
+ )
+ http2? (
+ >=dev-python/h2-3.2[${PYTHON_USEDEP}]
+ >=dev-python/priority-1.1.0[${PYTHON_USEDEP}]
+ )
+ serial? (
+ >=dev-python/pyserial-3.0[${PYTHON_USEDEP}]
+ )
+ ssl? (
+ >=dev-python/pyopenssl-21.0.0[${PYTHON_USEDEP}]
+ >=dev-python/service-identity-18.1.0[${PYTHON_USEDEP}]
+ >=dev-python/idna-2.4[${PYTHON_USEDEP}]
+ )
+ websockets? (
+ dev-python/wsproto[${PYTHON_USEDEP}]
+ )
+"
+IDEPEND="
+ >=dev-python/attrs-19.2.0[${PYTHON_USEDEP}]
+ >=dev-python/constantly-15.1[${PYTHON_USEDEP}]
+ >=dev-python/typing-extensions-4.2.0[${PYTHON_USEDEP}]
+ >=dev-python/zope-interface-5[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ >=dev-python/hatch-fancy-pypi-readme-22.5.0[${PYTHON_USEDEP}]
+ >=dev-python/incremental-22.10.0[${PYTHON_USEDEP}]
+ test? (
+ ${RDEPEND}
+ $(python_gen_cond_dep '
+ >=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
+ >=dev-python/bcrypt-3.0.0[${PYTHON_USEDEP}]
+ >=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
+ <dev-python/cython-test-exception-raiser-2[${PYTHON_USEDEP}]
+ >=dev-python/cython-test-exception-raiser-1.0.2[${PYTHON_USEDEP}]
+ >=dev-python/idna-2.4[${PYTHON_USEDEP}]
+ >=dev-python/httpx-0.27[${PYTHON_USEDEP}]
+ >=dev-python/hypothesis-6.56[${PYTHON_USEDEP}]
+ dev-python/pyasn1[${PYTHON_USEDEP}]
+ >=dev-python/pyhamcrest-2[${PYTHON_USEDEP}]
+ >=dev-python/pyserial-3.0[${PYTHON_USEDEP}]
+ dev-python/wsproto[${PYTHON_USEDEP}]
+ virtual/openssh
+ ssl? (
+ >=dev-python/pyopenssl-21.0.0[${PYTHON_USEDEP}]
+ >=dev-python/service-identity-18.1.0[${PYTHON_USEDEP}]
+ )
+ ' "${PYTHON_TESTED[@]}")
+ )
+"
+
+python_prepare_all() {
+ local PATCHES=(
+ # https://github.com/twisted/twisted/pull/12460
+ "${FILESDIR}/${P}-rebuild.patch"
+ # https://github.com/twisted/twisted/pull/12508
+ "${FILESDIR}/${P}-py314.patch"
+ )
+
+ distutils-r1_python_prepare_all
+
+ # upstream test for making releases; not very useful and requires
+ # sphinx (including on py2)
+ rm src/twisted/python/test/test_release.py || die
+
+ # multicast tests fail within network-sandbox
+ sed -e 's:test_joinLeave:_&:' \
+ -e 's:test_loopback:_&:' \
+ -e 's:test_multiListen:_&:' \
+ -e 's:test_multicast:_&:' \
+ -i src/twisted/test/test_udp.py || die
+}
+
+src_test() {
+ # the test suite handles missing file & failing ioctl()s gracefully
+ # but not permission errors from sandbox
+ addwrite /dev/net/tun
+ virtx distutils-r1_src_test
+}
+
+python_test() {
+ if ! has "${EPYTHON}" "${PYTHON_TESTED[@]/_/.}"; then
+ einfo "Skipping tests on ${EPYTHON} (xfail)"
+ return
+ fi
+
+ # breaks some tests by overriding empty environment
+ local -x SANDBOX_ON=0
+ # for py3.13, see
+ # https://github.com/twisted/twisted/pull/12092#issuecomment-2194326096
+ local -x LINES=25 COLUMNS=80
+ "${EPYTHON}" -m twisted.trial -j "$(makeopts_jobs)" twisted ||
+ die "Tests failed with ${EPYTHON}"
+}
+
+python_install() {
+ distutils-r1_python_install
+
+ # own the dropin.cache so we don't leave orphans
+ > "${D}$(python_get_sitedir)"/twisted/plugins/dropin.cache || die
+
+ python_doscript "${WORKDIR}"/twisted-regen-cache
+}
+
+python_install_all() {
+ distutils-r1_python_install_all
+
+ newconfd "${FILESDIR}/twistd.conf" twistd
+ newinitd "${FILESDIR}/twistd.init" twistd
+}
+
+python_postinst() {
+ twisted-regen-cache || die
+}
+
+pkg_postinst() {
+ if [[ -z ${ROOT} ]]; then
+ python_foreach_impl python_postinst
+ fi
+}
+
+python_postrm() {
+ rm -f "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache" || die
+}
+
+pkg_postrm() {
+ # if we're removing the last version, remove the cache file
+ if [[ ! ${REPLACING_VERSIONS} ]]; then
+ python_foreach_impl python_postrm
+ fi
+}