nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 replaceVars,
7 isPy310,
8 isPyPy,
9 pythonOlder,
10
11 # build-system
12 cython,
13 pkgconfig,
14 setuptools,
15
16 # native dependencies
17 llhttp,
18
19 # dependencies
20 aiohappyeyeballs,
21 aiosignal,
22 async-timeout,
23 attrs,
24 backports-zstd,
25 frozenlist,
26 multidict,
27 propcache,
28 yarl,
29
30 # optional dependencies
31 aiodns,
32 brotli,
33 brotlicffi,
34
35 # tests
36 blockbuster,
37 freezegun,
38 gunicorn,
39 isa-l,
40 isal,
41 proxy-py,
42 pytest-codspeed,
43 pytest-cov-stub,
44 pytest-mock,
45 pytest-xdist,
46 pytestCheckHook,
47 re-assert,
48 trustme,
49 zlib-ng,
50}:
51
52buildPythonPackage rec {
53 pname = "aiohttp";
54 version = "3.13.3";
55 pyproject = true;
56
57 src = fetchFromGitHub {
58 owner = "aio-libs";
59 repo = "aiohttp";
60 tag = "v${version}";
61 hash = "sha256-V+digrfigdA3hwd2xW47BACh3r07j6pGE8WFAGivZnA=";
62 };
63
64 postPatch = ''
65 rm -r vendor
66 patchShebangs tools
67 touch .git # tools/gen.py uses .git to find the project root
68
69 # don't install Cython using pip
70 substituteInPlace Makefile \
71 --replace-fail "cythonize: .install-cython" "cythonize:"
72 '';
73
74 build-system = [
75 cython
76 pkgconfig
77 setuptools
78 ];
79
80 preBuild = ''
81 make cythonize
82 '';
83
84 buildInputs = [
85 llhttp
86 ];
87
88 env.AIOHTTP_USE_SYSTEM_DEPS = true;
89
90 dependencies = [
91 aiohappyeyeballs
92 aiosignal
93 attrs
94 frozenlist
95 multidict
96 propcache
97 yarl
98 ]
99 ++ lib.optionals (pythonOlder "3.11") [
100 async-timeout
101 ]
102 ++ optional-dependencies.speedups;
103
104 optional-dependencies.speedups = [
105 aiodns
106 (if isPyPy then brotlicffi else brotli)
107 ]
108 ++ lib.optionals (pythonOlder "3.14") [
109 backports-zstd
110 ];
111
112 nativeCheckInputs = [
113 blockbuster
114 freezegun
115 gunicorn
116 # broken on aarch64-darwin
117 (if lib.meta.availableOn stdenv.hostPlatform isa-l then isal else null)
118 proxy-py
119 pytest-codspeed
120 pytest-cov-stub
121 pytest-mock
122 pytest-xdist
123 pytestCheckHook
124 re-assert
125 trustme
126 zlib-ng
127 ];
128
129 disabledTests = [
130 # Disable tests that require network access
131 "test_client_session_timeout_zero"
132 "test_mark_formdata_as_processed"
133 "test_requote_redirect_url_default"
134 "test_tcp_connector_ssl_shutdown_timeout_nonzero_passed"
135 "test_tcp_connector_ssl_shutdown_timeout_zero_not_passed"
136 "test_invalid_idna"
137 # don't run benchmarks
138 "test_import_time"
139 # racy
140 "test_uvloop_secure_https_proxy"
141 # Cannot connect to host example.com:443 ssl:default [Could not contact DNS servers]
142 "test_tcp_connector_ssl_shutdown_timeout_passed_to_create_connection"
143 ]
144 # these tests fail with python310 but succeeds with 11+
145 ++ lib.optionals isPy310 [
146 "test_https_proxy_unsupported_tls_in_tls"
147 "test_tcp_connector_raise_connector_ssl_error"
148 ]
149 ++ lib.optionals stdenv.hostPlatform.is32bit [ "test_cookiejar" ]
150 ++ lib.optionals stdenv.hostPlatform.isDarwin [
151 "test_addresses" # https://github.com/aio-libs/aiohttp/issues/3572, remove >= v4.0.0
152 "test_close"
153 ];
154
155 __darwinAllowLocalNetworking = true;
156
157 preCheck = ''
158 # aiohttp in current folder shadows installed version
159 rm -r aiohttp
160 touch tests/data.unknown_mime_type # has to be modified after 1 Jan 1990
161
162 export HOME=$(mktemp -d)
163 ''
164 + lib.optionalString stdenv.hostPlatform.isDarwin ''
165 # Work around "OSError: AF_UNIX path too long"
166 export TMPDIR="/tmp"
167 '';
168
169 meta = {
170 changelog = "https://docs.aiohttp.org/en/${src.tag}/changes.html";
171 description = "Asynchronous HTTP Client/Server for Python and asyncio";
172 license = lib.licenses.asl20;
173 homepage = "https://github.com/aio-libs/aiohttp";
174 maintainers = with lib.maintainers; [ dotlambda ];
175 };
176}