Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, buildPythonPackage
4, pythonOlder
5, fetchPypi
6, fetchpatch
7, python
8, appdirs
9, attrs
10, automat
11, bcrypt
12, constantly
13, cryptography
14, git
15, glibcLocales
16, h2
17, hyperlink
18, hypothesis
19, idna
20, incremental
21, priority
22, pyasn1
23, pyhamcrest
24, pynacl
25, pyopenssl
26, pyserial
27, service-identity
28, setuptools
29, typing-extensions
30, zope_interface
31
32 # for passthru.tests
33, cassandra-driver
34, klein
35, magic-wormhole
36, scrapy
37, treq
38, txaio
39, txamqp
40, txrequests
41, txtorcon
42, thrift
43, nixosTests
44}:
45
46buildPythonPackage rec {
47 pname = "twisted";
48 version = "22.10.0";
49 format = "setuptools";
50
51 disabled = pythonOlder "3.6";
52
53 src = fetchPypi {
54 pname = "Twisted";
55 inherit version;
56 extension = "tar.gz";
57 hash = "sha256-Mqy9QKlPX0bntCwQm/riswIlCUVWF4Oot6BZBI8tTTE=";
58 };
59
60 __darwinAllowLocalNetworking = true;
61
62 propagatedBuildInputs = [
63 attrs
64 automat
65 constantly
66 hyperlink
67 incremental
68 setuptools
69 typing-extensions
70 zope_interface
71 ];
72
73 postPatch = ''
74 echo 'ListingTests.test_localeIndependent.skip = "Timezone issue"'>> src/twisted/conch/test/test_cftp.py
75 echo 'ListingTests.test_newFile.skip = "Timezone issue"'>> src/twisted/conch/test/test_cftp.py
76 echo 'ListingTests.test_newSingleDigitDayOfMonth.skip = "Timezone issue"'>> src/twisted/conch/test/test_cftp.py
77 echo 'ListingTests.test_oldFile.skip = "Timezone issue"'>> src/twisted/conch/test/test_cftp.py
78 echo 'ListingTests.test_oldSingleDigitDayOfMonth.skip = "Timezone issue"'>> src/twisted/conch/test/test_cftp.py
79
80 echo 'UNIXTestsBuilder_AsyncioSelectorReactorTests.test_sendFileDescriptorTriggersPauseProducing.skip = "sendFileDescriptor producer was not paused"'>> src/twisted/internet/test/test_unix.py
81 echo 'UNIXTestsBuilder_SelectReactorTests.test_sendFileDescriptorTriggersPauseProducing.skip = "sendFileDescriptor producer was not paused"'>> src/twisted/internet/test/test_unix.py
82
83 echo 'FileObserverTests.test_getTimezoneOffsetEastOfUTC.skip = "mktime argument out of range"'>> src/twisted/test/test_log.py
84 echo 'FileObserverTests.test_getTimezoneOffsetWestOfUTC.skip = "mktime argument out of range"'>> src/twisted/test/test_log.py
85 echo 'FileObserverTests.test_getTimezoneOffsetWithoutDaylightSavingTime.skip = "tuple differs, values not"'>> src/twisted/test/test_log.py
86
87 echo 'MulticastTests.test_joinLeave.skip = "No such device"'>> src/twisted/test/test_udp.py
88 echo 'MulticastTests.test_loopback.skip = "No such device"'>> src/twisted/test/test_udp.py
89 echo 'MulticastTests.test_multicast.skip = "Reactor was unclean"'>> src/twisted/test/test_udp.py
90 echo 'MulticastTests.test_multiListen.skip = "No such device"'>> src/twisted/test/test_udp.py
91
92 # fails since migrating to libxcrypt
93 echo 'HelperTests.test_refuteCryptedPassword.skip = "OSError: Invalid argument"' >> src/twisted/conch/test/test_checkers.py
94
95 # not packaged
96 substituteInPlace src/twisted/test/test_failure.py \
97 --replace "from cython_test_exception_raiser import raiser # type: ignore[import]" "raiser = None"
98 '' + lib.optionalString stdenv.isLinux ''
99 echo 'PTYProcessTestsBuilder_EPollReactorTests.test_openFileDescriptors.skip = "invalid syntax"'>> src/twisted/internet/test/test_process.py
100 echo 'PTYProcessTestsBuilder_PollReactorTests.test_openFileDescriptors.skip = "invalid syntax"'>> src/twisted/internet/test/test_process.py
101 echo 'UNIXTestsBuilder_EPollReactorTests.test_sendFileDescriptorTriggersPauseProducing.skip = "sendFileDescriptor producer was not paused"'>> src/twisted/internet/test/test_unix.py
102 echo 'UNIXTestsBuilder_PollReactorTests.test_sendFileDescriptorTriggersPauseProducing.skip = "sendFileDescriptor producer was not paused"'>> src/twisted/internet/test/test_unix.py
103
104 # Patch t.p._inotify to point to libc. Without this,
105 # twisted.python.runtime.platform.supportsINotify() == False
106 substituteInPlace src/twisted/python/_inotify.py --replace \
107 "ctypes.util.find_library(\"c\")" "'${stdenv.cc.libc}/lib/libc.so.6'"
108 '' + lib.optionalString (stdenv.isAarch64 && stdenv.isDarwin) ''
109 echo 'AbortConnectionTests_AsyncioSelectorReactorTests.test_fullWriteBufferAfterByteExchange.skip = "Timeout after 120 seconds"' >> src/twisted/internet/test/test_tcp.py
110 echo 'AbortConnectionTests_AsyncioSelectorReactorTests.test_resumeProducingAbort.skip = "Timeout after 120 seconds"' >> src/twisted/internet/test/test_tcp.py
111
112 echo 'PosixReactorBaseTests.test_removeAllSkipsInternalReaders.skip = "Fails due to unclosed event loop"' >> src/twisted/internet/test/test_posixbase.py
113 echo 'PosixReactorBaseTests.test_wakerIsInternalReader.skip = "Fails due to unclosed event loop"' >> src/twisted/internet/test/test_posixbase.py
114
115 echo 'TCPPortTests.test_connectionLostFailed.skip = "Fails due to unclosed event loop"' >> src/twisted/internet/test/test_posixbase.py
116 '';
117
118 # Generate Twisted's plug-in cache. Twisted users must do it as well. See
119 # http://twistedmatrix.com/documents/current/core/howto/plugin.html#auto3
120 # and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477103 for details.
121 postFixup = ''
122 $out/bin/twistd --help > /dev/null
123 '';
124
125 checkInputs = [
126 git
127 glibcLocales
128 hypothesis
129 pyhamcrest
130 ]
131 ++ passthru.optional-dependencies.conch
132 # not supported on aarch64-darwin: https://github.com/pyca/pyopenssl/issues/873
133 ++ lib.optionals (!(stdenv.isDarwin && stdenv.isAarch64)) passthru.optional-dependencies.tls;
134
135 checkPhase = ''
136 export SOURCE_DATE_EPOCH=315532800
137 export PATH=$out/bin:$PATH
138 # race conditions when running in paralell
139 ${python.interpreter} -m twisted.trial twisted
140 '';
141
142 passthru = {
143 optional-dependencies = rec {
144 conch = [ appdirs bcrypt cryptography pyasn1 ];
145 conch_nacl = conch ++ [ pynacl ];
146 http2 = [ h2 priority ];
147 serial = [ pyserial ];
148 tls = [ idna pyopenssl service-identity ];
149 };
150
151 tests = {
152 inherit
153 cassandra-driver
154 klein
155 magic-wormhole
156 scrapy
157 treq
158 txaio
159 txamqp
160 txrequests
161 txtorcon
162 thrift;
163 inherit (nixosTests) buildbot matrix-synapse;
164 };
165 };
166
167 meta = with lib; {
168 homepage = "https://github.com/twisted/twisted";
169 description = "Asynchronous networking framework written in Python";
170 license = licenses.mit;
171 maintainers = with maintainers; [ SuperSandro2000 ];
172 };
173}