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 = "3.7.0";
32 format = "pyproject";
33
34 disabled = pythonOlder "3.7";
35
36 src = fetchFromGitHub {
37 owner = "agronholm";
38 repo = pname;
39 rev = version;
40 hash = "sha256-uXPp2ycYl3T/ybZihDchImC/Yi4qgHI37ZeA+I6dg4c=";
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 ] ++ lib.optionals stdenv.isDarwin [
88 # PermissionError: [Errno 1] Operation not permitted: '/dev/console'
89 "test_is_block_device"
90 ];
91
92 disabledTestPaths = [
93 # lots of DNS lookups
94 "tests/test_sockets.py"
95 ];
96
97 __darwinAllowLocalNetworking = true;
98
99 pythonImportsCheck = [ "anyio" ];
100
101 meta = with lib; {
102 changelog = "https://github.com/agronholm/anyio/blob/${src.rev}/docs/versionhistory.rst";
103 description = "High level compatibility layer for multiple asynchronous event loop implementations on Python";
104 homepage = "https://github.com/agronholm/anyio";
105 license = licenses.mit;
106 maintainers = with maintainers; [ hexa ];
107 };
108}