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