1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, pythonOlder
6
7# build-system
8, setuptools
9, setuptools-scm
10
11# dependencies
12, exceptiongroup
13, idna
14, sniffio
15
16# optionals
17, trio
18
19# tests
20, hypothesis
21, psutil
22, pytest-mock
23, pytest-xdist
24, pytestCheckHook
25, trustme
26, uvloop
27}:
28
29buildPythonPackage rec {
30 pname = "anyio";
31 version = "4.0.0";
32 format = "pyproject";
33
34 disabled = pythonOlder "3.7";
35
36 src = fetchFromGitHub {
37 owner = "agronholm";
38 repo = pname;
39 rev = "refs/tags/${version}";
40 hash = "sha256-gUFd2gHWIElYfzOvg7Yx7iJyhU6+iAcJpHTVsJtxTsk=";
41 };
42
43 env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
44
45 nativeBuildInputs = [
46 setuptools
47 setuptools-scm
48 ];
49
50 propagatedBuildInputs = [
51 idna
52 sniffio
53 ] ++ lib.optionals (pythonOlder "3.11") [
54 exceptiongroup
55 ];
56
57 passthru.optional-dependencies = {
58 trio = [
59 trio
60 ];
61 };
62
63 # trustme uses pyopenssl
64 doCheck = !(stdenv.isDarwin && stdenv.isAarch64);
65
66 nativeCheckInputs = [
67 hypothesis
68 psutil
69 pytest-mock
70 pytest-xdist
71 pytestCheckHook
72 trustme
73 ] ++ lib.optionals (pythonOlder "3.12") [
74 uvloop
75 ] ++ passthru.optional-dependencies.trio;
76
77 pytestFlagsArray = [
78 "-W" "ignore::trio.TrioDeprecationWarning"
79 "-m" "'not network'"
80 ];
81
82 disabledTests = [
83 # INTERNALERROR> AttributeError: 'NonBaseMultiError' object has no attribute '_exceptions'. Did you mean: 'exceptions'?
84 "test_exception_group_children"
85 "test_exception_group_host"
86 "test_exception_group_filtering"
87 # timing sensitive
88 # assert threading.active_count() == initial_count + 1
89 # assert 4 == (4 + 1)
90 "test_run_sync_from_thread_pooling"
91 ] ++ lib.optionals stdenv.isDarwin [
92 # PermissionError: [Errno 1] Operation not permitted: '/dev/console'
93 "test_is_block_device"
94 ];
95
96 disabledTestPaths = [
97 # lots of DNS lookups
98 "tests/test_sockets.py"
99 ];
100
101 __darwinAllowLocalNetworking = true;
102
103 pythonImportsCheck = [ "anyio" ];
104
105 meta = with lib; {
106 changelog = "https://github.com/agronholm/anyio/blob/${src.rev}/docs/versionhistory.rst";
107 description = "High level compatibility layer for multiple asynchronous event loop implementations on Python";
108 homepage = "https://github.com/agronholm/anyio";
109 license = licenses.mit;
110 maintainers = with maintainers; [ hexa ];
111 };
112}