1{
2 nodejs,
3 lib,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 poetry-core,
8 # install_requires
9 charset-normalizer,
10 h2,
11 onecache,
12 # test dependencies
13 asgiref,
14 black,
15 django,
16 click,
17 httpx,
18 proxy-py,
19 pytest-aiohttp,
20 pytest-asyncio,
21 pytest-django,
22 pytest-mock,
23 pytest-sugar,
24 pytest-timeout,
25 uvicorn,
26 httptools,
27 typed-ast,
28 uvloop,
29 requests,
30 aiohttp,
31 aiodns,
32 pytestCheckHook,
33 stdenv,
34}:
35
36buildPythonPackage rec {
37 pname = "aiosonic";
38 version = "0.22.0";
39 pyproject = true;
40
41 disabled = pythonOlder "3.8";
42
43 __darwinAllowLocalNetworking = true;
44
45 src = fetchFromGitHub {
46 owner = "sonic182";
47 repo = "aiosonic";
48 rev = "refs/tags/${version}";
49 hash = "sha256-wBYGiSTSRhi11uqTyGgF1YpnBVoDraCr2GKC8VkQEWc=";
50 };
51
52 postPatch = ''
53 substituteInPlace pytest.ini --replace-fail \
54 "addopts = --black --cov=aiosonic --cov-report term --cov-report html --doctest-modules" \
55 "addopts = --doctest-modules"
56 '';
57
58 build-system = [ poetry-core ];
59
60 dependencies = [
61 charset-normalizer
62 onecache
63 h2
64 ];
65
66 nativeCheckInputs = [
67 aiohttp
68 aiodns
69 asgiref
70 black
71 django
72 click
73 httpx
74 proxy-py
75 pytest-aiohttp
76 pytest-asyncio
77 pytest-django
78 pytest-mock
79 pytest-sugar
80 pytest-timeout
81 uvicorn
82 httptools
83 typed-ast
84 uvloop
85 requests
86 pytestCheckHook
87 nodejs
88 ];
89
90 pythonImportsCheck = [ "aiosonic" ];
91
92 disabledTests =
93 lib.optionals stdenv.hostPlatform.isLinux [
94 # need network
95 "test_simple_get"
96 "test_get_python"
97 "test_post_http2"
98 "test_get_http2"
99 "test_method_lower"
100 "test_keep_alive_smart_pool"
101 "test_keep_alive_cyclic_pool"
102 "test_get_with_params"
103 "test_get_with_params_in_url"
104 "test_get_with_params_tuple"
105 "test_post_form_urlencoded"
106 "test_post_tuple_form_urlencoded"
107 "test_post_json"
108 "test_put_patch"
109 "test_delete"
110 "test_delete_2"
111 "test_get_keepalive"
112 "test_post_multipart_to_django"
113 "test_connect_timeout"
114 "test_read_timeout"
115 "test_timeouts_overriden"
116 "test_pool_acquire_timeout"
117 "test_simple_get_ssl"
118 "test_simple_get_ssl_ctx"
119 "test_simple_get_ssl_no_valid"
120 "test_get_chunked_response"
121 "test_get_chunked_response_and_not_read_it"
122 "test_read_chunks_by_text_method"
123 "test_get_body_gzip"
124 "test_get_body_deflate"
125 "test_post_chunked"
126 "test_close_connection"
127 "test_close_old_keeped_conn"
128 "test_get_redirect"
129 "test_max_redirects"
130 "test_get_image"
131 "test_get_image_chunked"
132 "test_get_with_cookies"
133 "test_proxy_request"
134 ]
135 ++ lib.optionals stdenv.hostPlatform.isDarwin [
136 # "FAILED tests/test_proxy.py::test_proxy_request - Exception: port 8865 never got active"
137 "test_proxy_request"
138 ];
139
140 meta = {
141 changelog = "https://github.com/sonic182/aiosonic/blob/${version}/CHANGELOG.md";
142 description = "Very fast Python asyncio http client";
143 license = lib.licenses.mit;
144 homepage = "https://github.com/sonic182/aiosonic";
145 maintainers = with lib.maintainers; [ geraldog ];
146 };
147}