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