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 httpx,
14 pytest-aiohttp,
15 pytest-cov-stub,
16 pytest-mock,
17 uvicorn,
18 requests,
19 aiohttp,
20 pytestCheckHook,
21 stdenv,
22}:
23
24buildPythonPackage rec {
25 pname = "aiosonic";
26 version = "0.24.0";
27 pyproject = true;
28
29 disabled = pythonOlder "3.8";
30
31 __darwinAllowLocalNetworking = true;
32
33 src = fetchFromGitHub {
34 owner = "sonic182";
35 repo = "aiosonic";
36 tag = version;
37 hash = "sha256-Yh1AD/tBHQBpwAA86XuP9UuXnCAFcMw/XSv6z46XP0k=";
38 };
39
40 postPatch = ''
41 substituteInPlace pytest.ini --replace-fail \
42 "addopts = --black " \
43 "addopts = "
44 '';
45
46 build-system = [ poetry-core ];
47
48 dependencies = [
49 charset-normalizer
50 onecache
51 h2
52 ];
53
54 nativeCheckInputs = [
55 aiohttp
56 httpx
57 pytest-aiohttp
58 pytest-cov-stub
59 pytest-mock
60 uvicorn
61 requests
62 pytestCheckHook
63 ];
64
65 pythonImportsCheck = [ "aiosonic" ];
66
67 disabledTests =
68 lib.optionals stdenv.hostPlatform.isLinux [
69 # need network
70 "test_simple_get"
71 "test_get_python"
72 "test_post_http2"
73 "test_get_http2"
74 "test_method_lower"
75 "test_keep_alive_smart_pool"
76 "test_keep_alive_cyclic_pool"
77 "test_get_with_params"
78 "test_get_with_params_in_url"
79 "test_get_with_params_tuple"
80 "test_post_form_urlencoded"
81 "test_post_tuple_form_urlencoded"
82 "test_post_json"
83 "test_put_patch"
84 "test_delete"
85 "test_delete_2"
86 "test_get_keepalive"
87 "test_post_multipart_to_django"
88 "test_connect_timeout"
89 "test_read_timeout"
90 "test_timeouts_overriden"
91 "test_pool_acquire_timeout"
92 "test_simple_get_ssl"
93 "test_simple_get_ssl_ctx"
94 "test_simple_get_ssl_no_valid"
95 "test_get_chunked_response"
96 "test_get_chunked_response_and_not_read_it"
97 "test_read_chunks_by_text_method"
98 "test_get_body_gzip"
99 "test_get_body_deflate"
100 "test_post_chunked"
101 "test_close_connection"
102 "test_close_old_keeped_conn"
103 "test_get_redirect"
104 "test_max_redirects"
105 "test_get_image"
106 "test_get_image_chunked"
107 "test_get_with_cookies"
108 "test_proxy_request"
109 ]
110 ++ lib.optionals stdenv.hostPlatform.isDarwin [
111 # "FAILED tests/test_proxy.py::test_proxy_request - Exception: port 8865 never got active"
112 "test_proxy_request"
113 ];
114
115 meta = {
116 changelog = "https://github.com/sonic182/aiosonic/blob/${src.tag}/CHANGELOG.md";
117 description = "Very fast Python asyncio http client";
118 license = lib.licenses.mit;
119 homepage = "https://github.com/sonic182/aiosonic";
120 maintainers = with lib.maintainers; [ geraldog ];
121 };
122}