1{ lib, buildPythonPackage, fetchPypi, pythonOlder
2, attrs
3, sortedcontainers
4, async-generator
5, exceptiongroup
6, idna
7, outcome
8, pytestCheckHook
9, pytest-trio
10, pyopenssl
11, trustme
12, sniffio
13, stdenv
14, jedi
15, astor
16, yapf
17, coreutils
18}:
19
20let
21 # escape infinite recursion with pytest-trio
22 pytest-trio' = (pytest-trio.override {
23 trio = null;
24 }).overrideAttrs {
25 doCheck = false;
26 pythonImportsCheck = [];
27 };
28in
29buildPythonPackage rec {
30 pname = "trio";
31 version = "0.22.2";
32 format = "setuptools";
33 disabled = pythonOlder "3.7";
34
35 src = fetchPypi {
36 inherit pname version;
37 hash = "sha256-OIfPGMi8yJRDNCAwVGg4jax2ky6WaK+hxJqjgGtqzLM=";
38 };
39
40 propagatedBuildInputs = [
41 attrs
42 sortedcontainers
43 async-generator
44 idna
45 outcome
46 sniffio
47 ] ++ lib.optionals (pythonOlder "3.11") [
48 exceptiongroup
49 ];
50
51 # tests are failing on Darwin
52 doCheck = !stdenv.isDarwin;
53
54 nativeCheckInputs = [
55 astor
56 jedi
57 pyopenssl
58 pytestCheckHook
59 pytest-trio'
60 trustme
61 yapf
62 ];
63
64 preCheck = ''
65 substituteInPlace trio/_tests/test_subprocess.py \
66 --replace "/bin/sleep" "${coreutils}/bin/sleep"
67
68 export HOME=$TMPDIR
69 '';
70
71 # It appears that the build sandbox doesn't include /etc/services, and these tests try to use it.
72 disabledTests = [
73 "getnameinfo"
74 "SocketType_resolve"
75 "getprotobyname"
76 "waitpid"
77 "static_tool_sees_all_symbols"
78 # tests pytest more than python
79 "fallback_when_no_hook_claims_it"
80 # requires mypy
81 "test_static_tool_sees_class_members"
82 ];
83
84 pytestFlagsArray = [
85 "-W" "ignore::DeprecationWarning"
86 ];
87
88 meta = {
89 description = "An async/await-native I/O library for humans and snake people";
90 homepage = "https://github.com/python-trio/trio";
91 license = with lib.licenses; [ mit asl20 ];
92 maintainers = with lib.maintainers; [ catern ];
93 };
94}