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