nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, python
6, pythonOlder
7}:
8
9buildPythonPackage rec {
10 pname = "websockets";
11 version = "10.1";
12 format = "setuptools";
13
14 disabled = pythonOlder "3.7";
15
16 src = fetchFromGitHub {
17 owner = "aaugustin";
18 repo = pname;
19 rev = version;
20 sha256 = "sha256-FFaoqxa+TmKJ+P6T7HrwodjbVCir+2qJSfZsoj6deJU=";
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 checkPhase = ''
48 runHook preCheck
49 ${python.interpreter} -m unittest discover
50 runHook postCheck
51 '';
52
53 pythonImportsCheck = [
54 "websockets"
55 ];
56
57 meta = with lib; {
58 description = "WebSocket implementation in Python";
59 homepage = "https://websockets.readthedocs.io/";
60 license = licenses.bsd3;
61 maintainers = with maintainers; [ fab ];
62 };
63}