1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonOlder,
7
8 # build-system
9 setuptools-scm,
10
11 # dependencies
12 exceptiongroup,
13 idna,
14 sniffio,
15 typing-extensions,
16
17 # optionals
18 trio,
19
20 # tests
21 blockbuster,
22 hypothesis,
23 psutil,
24 pytest-mock,
25 pytest-xdist,
26 pytestCheckHook,
27 trustme,
28 uvloop,
29
30 # smoke tests
31 starlette,
32}:
33
34buildPythonPackage rec {
35 pname = "anyio";
36 version = "4.9.0";
37 pyproject = true;
38
39 disabled = pythonOlder "3.9";
40
41 src = fetchFromGitHub {
42 owner = "agronholm";
43 repo = "anyio";
44 tag = version;
45 hash = "sha256-kISaBHDkMOYYU9sdiQAXiq3jp1ehWOYFpvFbuceBWB0=";
46 };
47
48 build-system = [ setuptools-scm ];
49
50 dependencies =
51 [
52 idna
53 sniffio
54 ]
55 ++ lib.optionals (pythonOlder "3.13") [
56 typing-extensions
57 ]
58 ++ lib.optionals (pythonOlder "3.11") [
59 exceptiongroup
60 ];
61
62 optional-dependencies = {
63 trio = [ trio ];
64 };
65
66 nativeCheckInputs = [
67 blockbuster
68 exceptiongroup
69 hypothesis
70 psutil
71 pytest-mock
72 pytest-xdist
73 pytestCheckHook
74 trustme
75 uvloop
76 ] ++ optional-dependencies.trio;
77
78 pytestFlagsArray = [
79 "-W"
80 "ignore::trio.TrioDeprecationWarning"
81 "-m"
82 "'not network'"
83 ];
84
85 preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
86 # Work around "OSError: AF_UNIX path too long"
87 export TMPDIR="/tmp"
88 '';
89
90 disabledTests =
91 [
92 # TypeError: __subprocess_run() got an unexpected keyword argument 'umask'
93 "test_py39_arguments"
94 # AttributeError: 'module' object at __main__ has no attribute '__file__'
95 "test_nonexistent_main_module"
96 # 3 second timeout expired
97 "test_keyboardinterrupt_during_test"
98 ]
99 ++ lib.optionals stdenv.hostPlatform.isDarwin [
100 # PermissionError: [Errno 1] Operation not permitted: '/dev/console'
101 "test_is_block_device"
102
103 # These tests become flaky under heavy load
104 "test_asyncio_run_sync_called"
105 "test_handshake_fail"
106 "test_run_in_custom_limiter"
107 "test_cancel_from_shielded_scope"
108 "test_start_task_soon_cancel_later"
109
110 # AssertionError: assert 'wheel' == 'nixbld'
111 "test_group"
112 ];
113
114 disabledTestPaths = [
115 # lots of DNS lookups
116 "tests/test_sockets.py"
117 ];
118
119 __darwinAllowLocalNetworking = true;
120
121 pythonImportsCheck = [ "anyio" ];
122
123 passthru.tests = {
124 inherit starlette;
125 };
126
127 meta = with lib; {
128 changelog = "https://github.com/agronholm/anyio/blob/${src.tag}/docs/versionhistory.rst";
129 description = "High level compatibility layer for multiple asynchronous event loop implementations on Python";
130 homepage = "https://github.com/agronholm/anyio";
131 license = licenses.mit;
132 maintainers = with maintainers; [ hexa ];
133 };
134}