1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, pythonOlder
6# install_requires
7, attrs
8, charset-normalizer
9, multidict
10, async-timeout
11, yarl
12, frozenlist
13, aiosignal
14, aiodns
15, brotli
16, cchardet
17, asynctest
18, typing-extensions
19, idna-ssl
20# tests_require
21, async_generator
22, freezegun
23, gunicorn
24, pytest-mock
25, pytestCheckHook
26, re-assert
27, trustme
28}:
29
30buildPythonPackage rec {
31 pname = "aiohttp";
32 version = "3.8.3";
33 disabled = pythonOlder "3.6";
34
35 src = fetchPypi {
36 inherit pname version;
37 sha256 = "3828fb41b7203176b82fe5d699e0d845435f2374750a44b480ea6b930f6be269";
38 };
39
40 postPatch = ''
41 sed -i '/--cov/d' setup.cfg
42 '';
43
44 propagatedBuildInputs = [
45 attrs
46 charset-normalizer
47 multidict
48 async-timeout
49 yarl
50 typing-extensions
51 frozenlist
52 aiosignal
53 aiodns
54 brotli
55 cchardet
56 ] ++ lib.optionals (pythonOlder "3.8") [
57 asynctest
58 typing-extensions
59 ] ++ lib.optionals (pythonOlder "3.7") [
60 idna-ssl
61 ];
62
63 checkInputs = [
64 async_generator
65 freezegun
66 gunicorn
67 pytest-mock
68 pytestCheckHook
69 re-assert
70 ] ++ lib.optionals (!(stdenv.isDarwin && stdenv.isAarch64)) [
71 # Optional test dependency. Depends indirectly on pyopenssl, which is
72 # broken on aarch64-darwin.
73 trustme
74 ];
75
76 disabledTests = [
77 # Disable tests that require network access
78 "test_client_session_timeout_zero"
79 "test_mark_formdata_as_processed"
80 "test_requote_redirect_url_default"
81 # Disable tests that trigger deprecation warnings in pytest
82 "test_async_with_session"
83 "test_session_close_awaitable"
84 "test_close_run_until_complete_not_deprecated"
85 ] ++ lib.optionals stdenv.is32bit [
86 "test_cookiejar"
87 ] ++ lib.optionals stdenv.isDarwin [
88 "test_addresses" # https://github.com/aio-libs/aiohttp/issues/3572, remove >= v4.0.0
89 "test_close"
90 ];
91
92 disabledTestPaths = [
93 "test_proxy_functional.py" # FIXME package proxy.py
94 ];
95
96 __darwinAllowLocalNetworking = true;
97
98 # aiohttp in current folder shadows installed version
99 # Probably because we run `python -m pytest` instead of `pytest` in the hook.
100 preCheck = ''
101 cd tests
102 '' + lib.optionalString stdenv.isDarwin ''
103 # Work around "OSError: AF_UNIX path too long"
104 export TMPDIR="/tmp"
105 '';
106
107 meta = with lib; {
108 description = "Asynchronous HTTP Client/Server for Python and asyncio";
109 license = licenses.asl20;
110 homepage = "https://github.com/aio-libs/aiohttp";
111 maintainers = with maintainers; [ dotlambda ];
112 };
113}