1{ lib, stdenv, buildPythonPackage, fetchPypi, isPy27, isPyPy, mock, futures }:
2buildPythonPackage rec {
3 pname = "trollius";
4 version = "1.0.4";
5
6 src = fetchPypi {
7 inherit pname version;
8 sha256 = "0xny8y12x3wrflmyn6xi8a7n3m3ac80fgmgzphx5jbbaxkjcm148";
9 };
10
11 checkInputs = [ mock ];
12
13 propagatedBuildInputs = lib.optionals (isPy27 || isPyPy) [ futures ];
14
15 patches = [
16 ./tests.patch
17 ];
18
19 # Some of the tests fail on darwin with `error: AF_UNIX path too long'
20 # because of the *long* path names for sockets
21 patchPhase = lib.optionalString stdenv.isDarwin ''
22 sed -i -e "s|test_create_ssl_unix_connection|skip_test_create_ssl_unix_connection|g" tests/test_events.py
23 sed -i -e "s|test_create_unix_connection|skip_test_create_unix_connection|g" tests/test_events.py
24 sed -i -e "s|test_create_unix_server_existing_path_nonsock|skip_test_create_unix_server_existing_path_nonsock|g" tests/test_unix_events.py
25 sed -i -e "s|test_create_unix_server_existing_path_sock|skip_test_create_unix_server_existing_path_sock|g" tests/test_unix_events.py
26 sed -i -e "s|test_create_unix_server_ssl_verified|skip_test_create_unix_server_ssl_verified|g" tests/test_events.py
27 sed -i -e "s|test_create_unix_server_ssl_verify_failed|skip_test_create_unix_server_ssl_verify_failed|g" tests/test_events.py
28 sed -i -e "s|test_create_unix_server_ssl|skip_test_create_unix_server_ssl|g" tests/test_events.py
29 sed -i -e "s|test_create_unix_server|skip_test_create_unix_server|g" tests/test_events.py
30 sed -i -e "s|test_open_unix_connection_error|skip_test_open_unix_connection_error|g" tests/test_streams.py
31 sed -i -e "s|test_open_unix_connection_no_loop_ssl|skip_test_open_unix_connection_no_loop_ssl|g" tests/test_streams.py
32 sed -i -e "s|test_open_unix_connection|skip_test_open_unix_connection|g" tests/test_streams.py
33 sed -i -e "s|test_pause_reading|skip_test_pause_reading|g" tests/test_subprocess.py
34 sed -i -e "s|test_read_pty_output|skip_test_read_pty_output|g" tests/test_events.py
35 sed -i -e "s|test_start_unix_server|skip_test_start_unix_server|g" tests/test_streams.py
36 sed -i -e "s|test_unix_sock_client_ops|skip_test_unix_sock_client_ops|g" tests/test_events.py
37 sed -i -e "s|test_write_pty|skip_test_write_pty|g" tests/test_events.py
38 '';
39
40 meta = with stdenv.lib; {
41 description = "Port of the Tulip project (asyncio module, PEP 3156) on Python 2";
42 homepage = "https://bitbucket.org/enovance/trollius";
43 license = licenses.asl20;
44 maintainers = with maintainers; [ garbas ];
45 };
46}