1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 stdenv,
7
8 # build-system
9 setuptools,
10
11 # dependencies
12 attrs,
13 exceptiongroup,
14 idna,
15 outcome,
16 sniffio,
17 sortedcontainers,
18
19 # tests
20 astor,
21 jedi,
22 pyopenssl,
23 pytestCheckHook,
24 pytest-trio,
25 trustme,
26 yapf,
27}:
28
29let
30 # escape infinite recursion with pytest-trio
31 pytest-trio' = (pytest-trio.override { trio = null; }).overrideAttrs {
32 doCheck = false;
33 pythonImportsCheck = [ ];
34 };
35in
36buildPythonPackage rec {
37 pname = "trio";
38 version = "0.29.0";
39 pyproject = true;
40
41 disabled = pythonOlder "3.8";
42
43 src = fetchFromGitHub {
44 owner = "python-trio";
45 repo = "trio";
46 tag = "v${version}";
47 hash = "sha256-f77HXhXkPu2GMKCFqahfiP0EgpjyRqWaxzduqM2oXtA=";
48 };
49
50 build-system = [ setuptools ];
51
52 dependencies = [
53 attrs
54 idna
55 outcome
56 sniffio
57 sortedcontainers
58 ] ++ lib.optionals (pythonOlder "3.11") [ exceptiongroup ];
59
60 # tests are failing on Darwin
61 doCheck = !stdenv.hostPlatform.isDarwin;
62
63 nativeCheckInputs = [
64 astor
65 jedi
66 pyopenssl
67 pytestCheckHook
68 pytest-trio'
69 trustme
70 yapf
71 ];
72
73 preCheck = ''
74 export HOME=$TMPDIR
75 # $out is first in path which causes "import file mismatch"
76 PYTHONPATH=$PWD/src:$PYTHONPATH
77 '';
78
79 pytestFlagsArray = [
80 "-W"
81 "ignore::DeprecationWarning"
82 ];
83
84 # It appears that the build sandbox doesn't include /etc/services, and these tests try to use it.
85 disabledTests = [
86 "getnameinfo"
87 "SocketType_resolve"
88 "getprotobyname"
89 "waitpid"
90 "static_tool_sees_all_symbols"
91 # tests pytest more than python
92 "fallback_when_no_hook_claims_it"
93 # requires mypy
94 "test_static_tool_sees_class_members"
95 ];
96
97 disabledTestPaths = [
98 # linters
99 "src/trio/_tests/tools/test_gen_exports.py"
100 ];
101
102 meta = {
103 changelog = "https://github.com/python-trio/trio/blob/${src.tag}/docs/source/history.rst";
104 description = "Async/await-native I/O library for humans and snake people";
105 homepage = "https://github.com/python-trio/trio";
106 license = with lib.licenses; [
107 mit
108 asl20
109 ];
110 maintainers = with lib.maintainers; [ catern ];
111 };
112}