1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, unittestCheckHook
6, pythonOlder
7}:
8
9buildPythonPackage rec {
10 pname = "websockets";
11 version = "10.3";
12 format = "setuptools";
13
14 disabled = pythonOlder "3.7";
15
16 src = fetchFromGitHub {
17 owner = "aaugustin";
18 repo = pname;
19 rev = version;
20 hash = "sha256-ZUn/DvO1Kx7Uxne4DF/am69YL1c48qpgQrGek355Z+4=";
21 };
22
23 # Tests fail on Darwin with `OSError: AF_UNIX path too long`
24 doCheck = !stdenv.isDarwin;
25
26 patchPhase = ''
27 # Disable all tests that need to terminate within a predetermined amount of
28 # time. This is nondeterministic.
29 sed -i 's/with self.assertCompletesWithin.*:/if True:/' \
30 tests/legacy/test_protocol.py
31
32 # Disables tests relying on tight timeouts to avoid failures like:
33 # File "/build/source/tests/legacy/test_protocol.py", line 1270, in test_keepalive_ping_with_no_ping_timeout
34 # ping_1_again, ping_2 = tuple(self.protocol.pings)
35 # ValueError: too many values to unpack (expected 2)
36 for t in \
37 test_keepalive_ping_stops_when_connection_closing \
38 test_keepalive_ping_does_not_crash_when_connection_lost \
39 test_keepalive_ping \
40 test_keepalive_ping_not_acknowledged_closes_connection \
41 test_keepalive_ping_with_no_ping_timeout \
42 ; do
43 sed -i "s/def $t(/def skip_$t(/" tests/legacy/test_protocol.py
44 done
45 '';
46
47 checkInputs = [ unittestCheckHook ];
48
49 pythonImportsCheck = [
50 "websockets"
51 ];
52
53 meta = with lib; {
54 description = "WebSocket implementation in Python";
55 homepage = "https://websockets.readthedocs.io/";
56 license = licenses.bsd3;
57 maintainers = with maintainers; [ fab ];
58 };
59}