1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, fetchpatch
6, pythonOlder
7# build_requires
8, setuptools
9, wheel
10# install_requires
11, attrs
12, charset-normalizer
13, multidict
14, async-timeout
15, yarl
16, frozenlist
17, aiosignal
18, aiodns
19, brotli
20, faust-cchardet
21, typing-extensions
22# tests_require
23, async-generator
24, freezegun
25, gunicorn
26, pytest-mock
27, pytestCheckHook
28, re-assert
29, trustme
30}:
31
32buildPythonPackage rec {
33 pname = "aiohttp";
34 version = "3.8.6";
35 format = "pyproject";
36
37 disabled = pythonOlder "3.6";
38
39 src = fetchPypi {
40 inherit pname version;
41 hash = "sha256-sM8qRQG/+TMKilJItM6VGFHkFb3M6dwVjnbP1V4VCFw=";
42 };
43
44 patches = [
45 (fetchpatch {
46 # https://github.com/aio-libs/aiohttp/pull/7260
47 # Merged upstream, should be dropped once updated to 3.9.0
48 url = "https://github.com/aio-libs/aiohttp/commit/7dcc235cafe0c4521bbbf92f76aecc82fee33e8b.patch";
49 hash = "sha256-ZzhlE50bmA+e2XX2RH1FuWQHZIAa6Dk/hZjxPoX5t4g=";
50 })
51 ];
52
53 postPatch = ''
54 sed -i '/--cov/d' setup.cfg
55 '';
56
57 nativeBuildInputs = [
58 setuptools
59 wheel
60 ];
61
62 propagatedBuildInputs = [
63 attrs
64 charset-normalizer
65 multidict
66 async-timeout
67 yarl
68 typing-extensions
69 frozenlist
70 aiosignal
71 aiodns
72 brotli
73 faust-cchardet
74 ];
75
76 # NOTE: pytest-xdist cannot be added because it is flaky. See https://github.com/NixOS/nixpkgs/issues/230597 for more info.
77 nativeCheckInputs = [
78 async-generator
79 freezegun
80 gunicorn
81 pytest-mock
82 pytestCheckHook
83 re-assert
84 ] ++ lib.optionals (!(stdenv.isDarwin && stdenv.isAarch64)) [
85 # Optional test dependency. Depends indirectly on pyopenssl, which is
86 # broken on aarch64-darwin.
87 trustme
88 ];
89
90 disabledTests = [
91 # Disable tests that require network access
92 "test_client_session_timeout_zero"
93 "test_mark_formdata_as_processed"
94 "test_requote_redirect_url_default"
95 # Disable tests that trigger deprecation warnings in pytest
96 "test_async_with_session"
97 "test_session_close_awaitable"
98 "test_close_run_until_complete_not_deprecated"
99 # https://github.com/aio-libs/aiohttp/issues/7130
100 "test_static_file_if_none_match"
101 "test_static_file_if_match"
102 "test_static_file_if_modified_since_past_date"
103 ] ++ lib.optionals stdenv.is32bit [
104 "test_cookiejar"
105 ] ++ lib.optionals stdenv.isDarwin [
106 "test_addresses" # https://github.com/aio-libs/aiohttp/issues/3572, remove >= v4.0.0
107 "test_close"
108 ];
109
110 disabledTestPaths = [
111 "test_proxy_functional.py" # FIXME package proxy.py
112 ];
113
114 __darwinAllowLocalNetworking = true;
115
116 # aiohttp in current folder shadows installed version
117 # Probably because we run `python -m pytest` instead of `pytest` in the hook.
118 preCheck = ''
119 cd tests
120 '' + lib.optionalString stdenv.isDarwin ''
121 # Work around "OSError: AF_UNIX path too long"
122 export TMPDIR="/tmp"
123 '';
124
125 meta = with lib; {
126 changelog = "https://github.com/aio-libs/aiohttp/blob/v${version}/CHANGES.rst";
127 description = "Asynchronous HTTP Client/Server for Python and asyncio";
128 license = licenses.asl20;
129 homepage = "https://github.com/aio-libs/aiohttp";
130 maintainers = with maintainers; [ dotlambda ];
131 };
132}