1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, pythonOlder
6, setuptools
7, setuptools-scm
8, idna
9, sniffio
10, typing-extensions
11, curio
12, hypothesis
13, mock
14, pytest-mock
15, pytest-xdist
16, pytestCheckHook
17, trio
18, trustme
19, uvloop
20}:
21
22buildPythonPackage rec {
23 pname = "anyio";
24 version = "3.6.2";
25 format = "pyproject";
26 disabled = pythonOlder "3.7";
27
28 src = fetchFromGitHub {
29 owner = "agronholm";
30 repo = pname;
31 rev = version;
32 hash = "sha256-bootaulvx9zmobQGDirsMz5uxuLeCD9ggAvYkPaKnWo=";
33 };
34
35 preBuild = ''
36 export SETUPTOOLS_SCM_PRETEND_VERSION=${version}
37 '';
38
39 nativeBuildInputs = [
40 setuptools
41 setuptools-scm
42 ];
43
44 propagatedBuildInputs = [
45 idna
46 sniffio
47 ] ++ lib.optionals (pythonOlder "3.8") [
48 typing-extensions
49 ];
50
51 # trustme uses pyopenssl
52 doCheck = !(stdenv.isDarwin && stdenv.isAarch64);
53
54 nativeCheckInputs = [
55 curio
56 hypothesis
57 pytest-mock
58 pytest-xdist
59 pytestCheckHook
60 trio
61 trustme
62 uvloop
63 ] ++ lib.optionals (pythonOlder "3.8") [
64 mock
65 ];
66
67 pytestFlagsArray = [
68 "-W" "ignore::trio.TrioDeprecationWarning"
69 ];
70
71 disabledTests = [
72 # block devices access
73 "test_is_block_device"
74 # INTERNALERROR> AttributeError: 'NonBaseMultiError' object has no attribute '_exceptions'. Did you mean: 'exceptions'?
75 "test_exception_group_children"
76 "test_exception_group_host"
77 "test_exception_group_filtering"
78 # regression in python 3.11.3 and 3.10.11
79 # https://github.com/agronholm/anyio/issues/550
80 "TestTLSStream"
81 "TestTLSListener"
82 ];
83
84 disabledTestPaths = [
85 # lots of DNS lookups
86 "tests/test_sockets.py"
87 ] ++ lib.optionals stdenv.isDarwin [
88 # darwin sandboxing limitations
89 "tests/streams/test_tls.py"
90 ];
91
92 pythonImportsCheck = [ "anyio" ];
93
94 meta = with lib; {
95 changelog = "https://github.com/agronholm/anyio/blob/${src.rev}/docs/versionhistory.rst";
96 description = "High level compatibility layer for multiple asynchronous event loop implementations on Python";
97 homepage = "https://github.com/agronholm/anyio";
98 license = licenses.mit;
99 maintainers = with maintainers; [ hexa ];
100 };
101}