nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 unittestCheckHook,
7 pythonAtLeast,
8 pythonOlder,
9 setuptools,
10 werkzeug,
11}:
12
13buildPythonPackage rec {
14 pname = "websockets";
15 version = "16.0";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 owner = "aaugustin";
20 repo = "websockets";
21 tag = version;
22 hash = "sha256-75FkU45qbOb+xbJO4VKqfWBTep+Toh6OWch2WXnU4bg=";
23 };
24
25 build-system = [ setuptools ];
26
27 disabledTests = [
28 # Disables tests relying on tight timeouts to avoid failures like:
29 # File "/build/source/tests/legacy/test_protocol.py", line 1270, in test_keepalive_ping_with_no_ping_timeout
30 # ping_1_again, ping_2 = tuple(self.protocol.pings)
31 # ValueError: too many values to unpack (expected 2)
32 "test_keepalive_ping_stops_when_connection_closing"
33 "test_keepalive_ping_does_not_crash_when_connection_lost"
34 "test_keepalive_ping"
35 "test_keepalive_ping_not_acknowledged_closes_connection"
36 "test_keepalive_ping_with_no_ping_timeout"
37 ]
38 ++ lib.optionals (pythonAtLeast "3.13") [
39 # https://github.com/python-websockets/websockets/issues/1569
40 "test_writing_in_send_context_fails"
41 ]
42 ++ lib.optionals (pythonOlder "3.11") [
43 # Our Python 3.10 and older raise SSLError instead of SSLCertVerificationError
44 "test_reject_invalid_server_certificate"
45 ];
46
47 nativeCheckInputs = [
48 unittestCheckHook
49 werkzeug
50 ];
51
52 preCheck = ''
53 # https://github.com/python-websockets/websockets/issues/1509
54 export WEBSOCKETS_TESTS_TIMEOUT_FACTOR=100
55 # Disable all tests that need to terminate within a predetermined amount of
56 # time. This is nondeterministic.
57 sed -i 's/with self.assertCompletesWithin.*:/if True:/' \
58 tests/legacy/test_protocol.py
59 '';
60
61 # Tests fail on Darwin with `OSError: AF_UNIX path too long`
62 doCheck = !stdenv.hostPlatform.isDarwin;
63
64 pythonImportsCheck = [ "websockets" ];
65
66 meta = {
67 description = "WebSocket implementation in Python";
68 homepage = "https://websockets.readthedocs.io/";
69 changelog = "https://github.com/aaugustin/websockets/blob/${src.tag}/docs/project/changelog.rst";
70 license = lib.licenses.bsd3;
71 maintainers = with lib.maintainers; [ fab ];
72 };
73}