1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7,8,9} )
7 PYTHON_REQ_USE="threads(+)"
9 inherit distutils-r1 virtualx
12 TWISTED_P="${TWISTED_PN}-${PV}"
13 TWISTED_RELEASE=$(ver_cut 1-2)
15 DESCRIPTION="An asynchronous networking framework written in Python"
16 HOMEPAGE="https://www.twistedmatrix.com/trac/"
17 SRC_URI="https://twistedmatrix.com/Releases/${TWISTED_PN}"
18 SRC_URI="${SRC_URI}/${TWISTED_RELEASE}/${TWISTED_P}.tar.bz2
19 https://dev.gentoo.org/~mgorny/dist/twisted-regen-cache.gz"
21 KEYWORDS="~alpha amd64 arm ~arm64 ~mips ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux"
25 IUSE="conch crypt http2 serial test"
26 RESTRICT="!test? ( test )"
29 >=dev-python/attrs-19.2.0[${PYTHON_USEDEP}]
30 >=dev-python/automat-0.3.0[${PYTHON_USEDEP}]
31 >=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
32 >=dev-python/hyperlink-17.1.1[${PYTHON_USEDEP}]
33 >=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
34 >=dev-python/pyhamcrest-1.9.0[${PYTHON_USEDEP}]
35 >=dev-python/zope-interface-4.4.2[${PYTHON_USEDEP}]
37 dev-python/pyasn1[${PYTHON_USEDEP}]
38 >=dev-python/cryptography-1.5.0[${PYTHON_USEDEP}]
39 >=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
42 >=dev-python/pyopenssl-16.0.0[${PYTHON_USEDEP}]
43 dev-python/service_identity[${PYTHON_USEDEP}]
44 >=dev-python/idna-0.6[${PYTHON_USEDEP}]
46 serial? ( >=dev-python/pyserial-3.0[${PYTHON_USEDEP}] )
48 >=dev-python/hyper-h2-3.0.0[${PYTHON_USEDEP}]
49 <dev-python/hyper-h2-4.0.0[${PYTHON_USEDEP}]
50 >=dev-python/priority-1.1.0[${PYTHON_USEDEP}]
51 <dev-python/priority-2.0[${PYTHON_USEDEP}]
53 !dev-python/twisted-core
54 !dev-python/twisted-conch
55 !dev-python/twisted-lore
56 !dev-python/twisted-mail
57 !dev-python/twisted-names
58 !dev-python/twisted-news
59 !dev-python/twisted-pair
60 !dev-python/twisted-runner
61 !dev-python/twisted-words
62 !dev-python/twisted-web
66 >=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
68 dev-python/gmpy[${PYTHON_USEDEP}]
69 dev-python/pyasn1[${PYTHON_USEDEP}]
70 >=dev-python/cryptography-0.9.1[${PYTHON_USEDEP}]
71 >=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
72 >=dev-python/pyopenssl-0.13[${PYTHON_USEDEP}]
73 dev-python/service_identity[${PYTHON_USEDEP}]
74 dev-python/idna[${PYTHON_USEDEP}]
75 dev-python/pyserial[${PYTHON_USEDEP}]
76 >=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
81 S=${WORKDIR}/${TWISTED_P}
83 python_prepare_all() {
85 "${FILESDIR}"/twisted-20.3.0-py38-cgi.patch
86 "${FILESDIR}"/twisted-20.3.0-py38-hmac.patch
87 "${FILESDIR}"/twisted-20.3.0-py39-b64.patch
88 "${FILESDIR}"/twisted-20.3.0-py39-combined.patch
91 # upstream test for making releases; not very useful and requires
92 # sphinx (including on py2)
93 rm src/twisted/python/test/test_release.py || die
95 # Conch doesn't work with latest >=OpenSSH 7.6
96 # - https://twistedmatrix.com/trac/ticket/9311
97 # - https://twistedmatrix.com/trac/ticket/9515
98 rm src/twisted/conch/test/test_ckeygen.py || die
99 rm src/twisted/conch/test/test_conch.py || die
100 rm src/twisted/conch/test/test_cftp.py || die
102 # puts system in EMFILE state, then the exception handler may fail
103 # trying to open more files due to some gi magic
104 sed -e '/SKIP_EMFILE/s:None:"Fails on non-pristine systems":' \
105 -i src/twisted/internet/test/test_tcp.py || die
107 # multicast tests fail within network-sandbox
108 sed -e 's:test_joinLeave:_&:' \
109 -e 's:test_loopback:_&:' \
110 -e 's:test_multiListen:_&:' \
111 -e 's:test_multicast:_&:' \
112 -i src/twisted/test/test_udp.py || die
114 # accesses /dev/net/tun
115 sed -e '/class RealDeviceTestsMixin/a\
116 skip = "Requires extra permissions"' \
117 -i src/twisted/pair/test/test_tuntap.py || die
119 # TODO: figure it out, probably doesn't accept DST date here
120 sed -e 's:test_getTimezoneOffsetWithoutDaylightSavingTime:_&:' \
121 -i src/twisted/test/test_log.py || die
123 # TODO: failures specific to Python 2
124 sed -e 's:testLookupProcNetTcp:_&:' \
125 -i src/twisted/test/test_ident.py || die
126 sed -e 's:test_loggingFactoryOpensLogfileAutomatically:_&:' \
127 -i src/twisted/test/test_policies.py || die
129 distutils-r1_python_prepare_all
133 virtx distutils-r1_src_test
137 # TODO: upstream seems to override our build paths
138 distutils_install_for_testing
140 "${EPYTHON}" -m twisted.trial twisted ||
141 die "Tests failed with ${EPYTHON}"
145 distutils-r1_python_install
147 cd "${D}$(python_get_sitedir)" || die
149 # own the dropin.cache so we don't leave orphans
150 touch twisted/plugins/dropin.cache || die
152 python_doscript "${WORKDIR}"/twisted-regen-cache
155 python_install_all() {
156 distutils-r1_python_install_all
158 newconfd "${FILESDIR}/twistd.conf" twistd
159 newinitd "${FILESDIR}/twistd.init" twistd
163 twisted-regen-cache || die
167 python_foreach_impl python_postinst
169 einfo "Install complete"
172 einfo "Some tests have been disabled during testing due to"
173 einfo "known incompatibilities with the emerge sandboxes and/or"
174 einfo "not runnable as the root user."
175 einfo "For a complete test suite run on the code."
176 einfo "Run the tests as a normal user for each python it is installed to."
177 einfo " ie: $ python3.6 /usr/bin/trial twisted"
182 rm -f "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache" || die
186 # if we're removing the last version, remove the cache file
187 if [[ ! ${REPLACING_VERSIONS} ]]; then
188 python_foreach_impl python_postrm