commit: 59c2cc6440219236e243dc1c1873ce5132b43011 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sat Jun 7 13:53:47 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sat Jun 7 14:17:19 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59c2cc64
dev-python/twisted: Bump to 25.5.0 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> dev-python/twisted/Manifest | 1 + .../twisted/files/twisted-25.5.0-rebuild.patch | 41 +++++ dev-python/twisted/twisted-25.5.0.ebuild | 168 +++++++++++++++++++++ 3 files changed, 210 insertions(+) diff --git a/dev-python/twisted/Manifest b/dev-python/twisted/Manifest index 623b687189b4..5030fbdf8058 100644 --- a/dev-python/twisted/Manifest +++ b/dev-python/twisted/Manifest @@ -1,4 +1,5 @@ DIST twisted-24.10.0.tar.gz 3525999 BLAKE2B 4d274a4b5989597c2789e05774bad3595ac5284f5da25fb488d46b87a4bb0e0ab311fcab228eaf070530451a28098bbefc326f6d4806378b2fe076adf5b07199 SHA512 dad7c1301c3b31f096db8c4796e064e864c2c28107c46c202b4f4b123c99a0e69f9b43afbf582997dd2c15a08e95b41213e4bc67ea1fe9fd8137c76656a20162 DIST twisted-24.11.0.tar.gz 3526722 BLAKE2B cd874da038e3cbc369283de5d598b99680e3122ed9bdd0bbb8e541793b739b88281708c618c8f0cf9b4bf13684188b0b893ec5f744ae510c1af446822652a866 SHA512 cfd17cad9573b47b43761625ab529a1a0b27ce75545d9bc277622a7ce138b5dccf554d3c8764de1baafc07192e1172e50f4c6d19dc65590b5318a603a808efb9 +DIST twisted-25.5.0.tar.gz 3545725 BLAKE2B 01f24c3c90c3db349efe779a8262abab3004782aedd8534a8c53e5336d77862a3615c83093137074b19af415cdb5572e07c39a74846a128544e8405d9c69864b SHA512 3d023777854fdf54e06f4bbaf3159359767aac9ba33e90d2b2e8abe29815d088e00eebd06944c12610a28c517d9cb397a5104ff153160edabfb91dd16a15f597 DIST twisted-25.5.0rc1.tar.gz 3546085 BLAKE2B adf18b8755d431ea47fa07ec6cbf32e6400ae928e3246782035785856b843e0e31bca448441ad2b280cbc874708ae521c39d0194b32fd6aa45ce3ce5fe977c64 SHA512 e67e1a1c19a49cfcd9179e2b981539dac87e19b46b630de41542fc3d34efa508ee624b6640b5a3186450251ee1a610dced5ab093b025607c0e61bfa843eb4b68 DIST twisted-regen-cache.gz 911 BLAKE2B ffd3fcda6c67ffe6fd3ef581c8d507548396b66ed0708e9a5c790095e579c0d5f0f71596acf05712989da2ddef2b8d437eca973bc4d80ef8a9fa852915f38305 SHA512 95a9b931c73017d16d1b5e6b41345dddffe62b6af1a8e93b5e40d06d3d15be17b0dd0181c767ffeeb791534d463764ef9e066fa6c2ee2ac4b53c86d1da8fce03 diff --git a/dev-python/twisted/files/twisted-25.5.0-rebuild.patch b/dev-python/twisted/files/twisted-25.5.0-rebuild.patch new file mode 100644 index 000000000000..e92595c7649e --- /dev/null +++ b/dev-python/twisted/files/twisted-25.5.0-rebuild.patch @@ -0,0 +1,41 @@ +From bd88d363bc9aa985131a9c2bb06ab37497e33173 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sun, 25 May 2025 18:53:56 +0200 +Subject: [PATCH] Fix `rebuild()` to handle changing `sys.modules` gracefully + +Copy keys from `sys.modules` before starting to iterate over it +in the `rebuild()` function, and handle missing modules gracefully, +in order to fix possible "directionary changed size during iteration" +errors. In particular, this can happen when iterating over the `py` +module. + +Fixes #12458 +--- + src/twisted/newsfragments/12458.bugfix | 1 + + src/twisted/python/rebuild.py | 5 ++++- + 2 files changed, 5 insertions(+), 1 deletion(-) + create mode 100644 src/twisted/newsfragments/12458.bugfix + +diff --git a/src/twisted/newsfragments/12458.bugfix b/src/twisted/newsfragments/12458.bugfix +new file mode 100644 +index 00000000000..df61eb384af +--- /dev/null ++++ b/src/twisted/newsfragments/12458.bugfix +@@ -0,0 +1 @@ ++twisted.python.rebuild.rebuild() now handles changes to ``sys.modules`` gracefully. Prior to the change, it could possibly raise a "dictionary changed size during iteration" error if the module list changed. +diff --git a/src/twisted/python/rebuild.py b/src/twisted/python/rebuild.py +index e82beec1b6a..4ab7e0533d0 100644 +--- a/src/twisted/python/rebuild.py ++++ b/src/twisted/python/rebuild.py +@@ -210,7 +210,10 @@ def rebuild(module, doLog=1): + log.msg("") + log.msg(f" (fixing {str(module.__name__)}): ") + modcount = 0 +- for mk, mod in sys.modules.items(): ++ # note: sys.modules can change throughout iteration ++ # https://github.com/twisted/twisted/issues/12458 ++ for mk in list(sys.modules): ++ mod = sys.modules.get(mk) + modcount = modcount + 1 + if mod == module or mod is None: + continue diff --git a/dev-python/twisted/twisted-25.5.0.ebuild b/dev-python/twisted/twisted-25.5.0.ebuild new file mode 100644 index 000000000000..b5568cf3bfa0 --- /dev/null +++ b/dev-python/twisted/twisted-25.5.0.ebuild @@ -0,0 +1,168 @@ +# 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/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" + ) + + 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 +}
