1{ lib, stdenv
2, buildPythonPackage
3, fetchPypi
4, python
5, zope_interface
6, incremental
7, automat
8, constantly
9, hyperlink
10, pyhamcrest
11, attrs
12, pyopenssl
13, service-identity
14, setuptools
15, idna
16, typing-extensions
17}:
18buildPythonPackage rec {
19 pname = "Twisted";
20 version = "21.7.0";
21
22 src = fetchPypi {
23 inherit pname version;
24 extension = "tar.gz";
25 sha256 = "01lh225d7lfnmfx4f4kxwl3963gjc9yg8jfkn1w769v34ia55mic";
26 };
27
28 propagatedBuildInputs = [ zope_interface incremental automat constantly hyperlink pyhamcrest attrs setuptools typing-extensions ];
29
30 passthru.extras.tls = [ pyopenssl service-identity idna ];
31
32 # Patch t.p._inotify to point to libc. Without this,
33 # twisted.python.runtime.platform.supportsINotify() == False
34 patchPhase = lib.optionalString stdenv.isLinux ''
35 substituteInPlace src/twisted/python/_inotify.py --replace \
36 "ctypes.util.find_library(\"c\")" "'${stdenv.glibc.out}/lib/libc.so.6'"
37 '';
38
39 # Generate Twisted's plug-in cache. Twisted users must do it as well. See
40 # http://twistedmatrix.com/documents/current/core/howto/plugin.html#auto3
41 # and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477103 for
42 # details.
43 postFixup = ''
44 $out/bin/twistd --help > /dev/null
45 '';
46
47 checkPhase = ''
48 ${python.interpreter} -m unittest discover -s twisted/test
49 '';
50 # Tests require network
51 doCheck = false;
52
53 meta = with lib; {
54 homepage = "https://twistedmatrix.com/";
55 description = "Twisted, an event-driven networking engine written in Python";
56 longDescription = ''
57 Twisted is an event-driven networking engine written in Python
58 and licensed under the MIT license.
59 '';
60 license = licenses.mit;
61 maintainers = [ ];
62 };
63}