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