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}:
27
28let
29 # escape infinite recursion with pytest-trio
30 pytest-trio' = (pytest-trio.override { trio = null; }).overrideAttrs {
31 # `pythonRemoveDeps` is not working properly
32 dontCheckRuntimeDeps = true;
33 doCheck = false;
34 pythonImportsCheck = [ ];
35 };
36in
37buildPythonPackage rec {
38 pname = "trio";
39 version = "0.30.0";
40 pyproject = true;
41
42 disabled = pythonOlder "3.8";
43
44 src = fetchFromGitHub {
45 owner = "python-trio";
46 repo = "trio";
47 tag = "v${version}";
48 hash = "sha256-spYHwVq3iNhnZQf2z7aTyDuSCiSl3X5PD6siXqLC4EA=";
49 };
50
51 build-system = [ setuptools ];
52
53 dependencies = [
54 attrs
55 idna
56 outcome
57 sniffio
58 sortedcontainers
59 ]
60 ++ lib.optionals (pythonOlder "3.11") [ exceptiongroup ];
61
62 # tests are failing on Darwin
63 doCheck = !stdenv.hostPlatform.isDarwin;
64
65 nativeCheckInputs = [
66 astor
67 jedi
68 pyopenssl
69 pytestCheckHook
70 pytest-trio'
71 trustme
72 ];
73
74 preCheck = ''
75 export HOME=$TMPDIR
76 # $out is first in path which causes "import file mismatch"
77 PYTHONPATH=$PWD/src:$PYTHONPATH
78 '';
79
80 pytestFlags = [
81 "-Wignore::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}