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