1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python2_7 python3_6)
6 PYTHON_REQ_USE="threads(+)"
8 inherit eutils flag-o-matic distutils-r1 versionator
11 TWISTED_P="${TWISTED_PN}-${PV}"
12 TWISTED_RELEASE=$(get_version_component_range 1-2 "${PV}")
14 DESCRIPTION="An asynchronous networking framework written in Python"
15 HOMEPAGE="https://www.twistedmatrix.com/trac/"
16 SRC_URI="https://twistedmatrix.com/Releases/${TWISTED_PN}"
17 SRC_URI="${SRC_URI}/${TWISTED_RELEASE}/${TWISTED_P}.tar.bz2
18 https://dev.gentoo.org/~mgorny/dist/twisted-regen-cache.gz"
20 # Dropped keywords due to new deps not keyworded
21 #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~ppc ~ppc64 ~s390 ~sh ~x86 ~ia64-hpux ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
22 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 sparc x86"
26 IUSE="conch crypt http2 serial +soap test"
27 RESTRICT="!test? ( test )"
30 >=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
31 >=dev-python/zope-interface-4.0.2[${PYTHON_USEDEP}]
33 dev-python/pyasn1[${PYTHON_USEDEP}]
34 >=dev-python/cryptography-0.9.1[${PYTHON_USEDEP}]
35 >=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
38 >=dev-python/pyopenssl-16.0.0[${PYTHON_USEDEP}]
39 dev-python/service_identity[${PYTHON_USEDEP}]
40 >=dev-python/idna-0.6[${PYTHON_USEDEP}]
42 serial? ( dev-python/pyserial[${PYTHON_USEDEP}] )
43 soap? ( $(python_gen_cond_dep 'dev-python/soappy[${PYTHON_USEDEP}]' python2_7) )
45 >=dev-python/hyper-h2-2.5.0[${PYTHON_USEDEP}]
46 <dev-python/hyper-h2-3.0.0[${PYTHON_USEDEP}]
47 >=dev-python/priority-1.1.0[${PYTHON_USEDEP}]
48 <dev-python/priority-2.0[${PYTHON_USEDEP}]
50 >=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
51 !dev-python/twisted-core
52 !dev-python/twisted-conch
53 !dev-python/twisted-lore
54 !dev-python/twisted-mail
55 !dev-python/twisted-names
56 !dev-python/twisted-news
57 !dev-python/twisted-pair
58 !dev-python/twisted-runner
59 !dev-python/twisted-words
60 !dev-python/twisted-web
63 >=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
65 dev-python/gmpy[${PYTHON_USEDEP}]
66 dev-python/pyasn1[${PYTHON_USEDEP}]
67 >=dev-python/cryptography-0.9.1[${PYTHON_USEDEP}]
68 >=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
69 >=dev-python/pyopenssl-0.13[${PYTHON_USEDEP}]
70 dev-python/service_identity[${PYTHON_USEDEP}]
71 dev-python/idna[${PYTHON_USEDEP}]
72 dev-python/pyserial[${PYTHON_USEDEP}]
73 >=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
78 # Respect TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE variable.
79 "${FILESDIR}/${PN}-16.5.0-respect_TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE.patch"
80 "${FILESDIR}/test_main.patch"
81 "${FILESDIR}/utf8_overrides.patch"
82 "${FILESDIR}/${PN}-16.6.0-test-fixes.patch"
85 S=${WORKDIR}/${TWISTED_P}
87 python_prepare_all() {
88 # disable tests that don't work in our sandbox
89 # and other test failures due to our conditions
91 # Remove since this is an upstream distribution test for making releases
92 rm src/twisted/python/test/test_release.py || die "rm src/twisted/python/test/test_release.py FAILED"
94 distutils-r1_python_prepare_all
98 if ! python_is_python3; then
99 # Needed to make the sendmsg extension work
100 # (see https://twistedmatrix.com/trac/ticket/5701 )
101 local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
102 local -x CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
105 distutils-r1_python_compile
109 distutils_install_for_testing
111 export EMERGE_TEST_OVERRIDE=1
112 export UTF8_OVERRIDES=1
113 # workaround for the eclass not installing the entry points
114 # in the test environment. copy the old 16.3.2 start script
115 # to run the tests with
116 cp "${FILESDIR}"/trial "${TEST_DIR}" || die
117 chmod +x "${TEST_DIR}"/trial || die
119 pushd "${TEST_DIR}" > /dev/null || die
121 if ! "${TEST_DIR}"/trial twisted; then
122 die "Tests failed with ${EPYTHON}"
124 # due to an anomoly in the tests, python doesn't return the correct form
125 # of the escape sequence. So run those test separately with a clean python interpreter
126 export UTF8_OVERRIDES=0
127 if ! "${TEST_DIR}"/trial twisted.test.test_twistd.DaemonizeTests; then
128 die "DaemonizeTests failed with ${EPYTHON}"
130 if ! "${TEST_DIR}"/trial twisted.test.test_reflect.SafeStrTests; then
131 die "SafeStrTests failed with ${EPYTHON}"
134 popd > /dev/null || die
138 distutils-r1_python_install
140 cd "${D%/}$(python_get_sitedir)" || die
142 # own the dropin.cache so we don't leave orphans
143 touch twisted/plugins/dropin.cache || die
145 python_doscript "${WORKDIR}"/twisted-regen-cache
148 python_install_all() {
149 distutils-r1_python_install_all
151 newconfd "${FILESDIR}/twistd.conf" twistd
152 newinitd "${FILESDIR}/twistd.init" twistd
156 twisted-regen-cache || die
160 python_foreach_impl python_postinst
162 einfo "Install complete"
165 einfo "Some tests have been disabled during testing due to"
166 einfo "known incompatibilities with the emerge sandboxes and/or"
167 einfo "not runnable as the root user."
168 einfo "For a complete test suite run on the code."
169 einfo "Run the tests as a normal user for each python it is installed to."
170 einfo " ie: $ python3.6 /usr/bin/trial twisted"
171 einfo "There are a few known python-2.7 errors due to some unicode issues"
172 einfo "which are different in Gentoo installed python-2.7"
177 rm -f "${ROOT%/}$(python_get_sitedir)/twisted/plugins/dropin.cache" || die
181 # if we're removing the last version, remove the cache file
182 if [[ ! ${REPLACING_VERSIONS} ]]; then
183 python_foreach_impl python_postrm