nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.12.1";
37 pyproject = true;
38
39 src = fetchFromGitHub {
40 owner = "agronholm";
41 repo = "anyio";
42 tag = version;
43 hash = "sha256-7rfQ6mwB2sNKc28ZPMZNgVs7TFgBUBzH6xGXmtfzX9k=";
44 };
45
46 build-system = [ setuptools-scm ];
47
48 dependencies = [
49 idna
50 sniffio
51 ]
52 ++ lib.optionals (pythonOlder "3.13") [
53 typing-extensions
54 ]
55 ++ lib.optionals (pythonOlder "3.11") [
56 exceptiongroup
57 ];
58
59 optional-dependencies = {
60 trio = [ trio ];
61 };
62
63 nativeCheckInputs = [
64 blockbuster
65 exceptiongroup
66 hypothesis
67 psutil
68 pytest-mock
69 pytest-xdist
70 pytestCheckHook
71 trustme
72 uvloop
73 ]
74 ++ optional-dependencies.trio;
75
76 pytestFlags = [
77 "-Wignore::trio.TrioDeprecationWarning"
78 # DeprecationWarning for asyncio.iscoroutinefunction is propagated from uvloop used internally
79 # https://github.com/agronholm/anyio/commit/e7bb0bd496b1ae0d1a81b86de72312d52e8135ed
80 "-Wignore::DeprecationWarning"
81 ];
82
83 disabledTestMarks = [
84 "network"
85 ];
86
87 preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
88 # Work around "OSError: AF_UNIX path too long"
89 export TMPDIR="/tmp"
90 '';
91
92 disabledTests = [
93 # TypeError: __subprocess_run() got an unexpected keyword argument 'umask'
94 "test_py39_arguments"
95 # AttributeError: 'module' object at __main__ has no attribute '__file__'
96 "test_nonexistent_main_module"
97 # 3 second timeout expired
98 "test_keyboardinterrupt_during_test"
99 # racy with high thread count, see https://github.com/NixOS/nixpkgs/issues/448125
100 "test_multiple_threads"
101 ]
102 ++ lib.optionals stdenv.hostPlatform.isDarwin [
103 # PermissionError: [Errno 1] Operation not permitted: '/dev/console'
104 "test_is_block_device"
105
106 # These tests become flaky under heavy load
107 "test_asyncio_run_sync_called"
108 "test_handshake_fail"
109 "test_run_in_custom_limiter"
110 "test_cancel_from_shielded_scope"
111 "test_start_task_soon_cancel_later"
112
113 # AssertionError: assert 'wheel' == 'nixbld'
114 "test_group"
115 ];
116
117 disabledTestPaths = [
118 # lots of DNS lookups
119 "tests/test_sockets.py"
120 ];
121
122 __darwinAllowLocalNetworking = true;
123
124 pythonImportsCheck = [ "anyio" ];
125
126 passthru.tests = {
127 inherit starlette;
128 };
129
130 meta = {
131 changelog = "https://github.com/agronholm/anyio/blob/${src.tag}/docs/versionhistory.rst";
132 description = "High level compatibility layer for multiple asynchronous event loop implementations on Python";
133 homepage = "https://github.com/agronholm/anyio";
134 license = lib.licenses.mit;
135 maintainers = with lib.maintainers; [ hexa ];
136 };
137}