1{ lib
2, anyio
3, buildPythonPackage
4, certifi
5, fetchFromGitHub
6, h11
7, h2
8, pproxy
9, pytest-asyncio
10, pytest-httpbin
11, pytest-trio
12, pytestCheckHook
13, pythonOlder
14, sniffio
15, socksio
16}:
17
18buildPythonPackage rec {
19 pname = "httpcore";
20 version = "0.16.3";
21 format = "setuptools";
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "encode";
27 repo = pname;
28 rev = "refs/tags/${version}";
29 hash = "sha256-3bC97CTZi6An+owjoJF7Irtr7ONbP8RtNdTIGJRy0Ng=";
30 };
31
32 propagatedBuildInputs = [
33 anyio
34 certifi
35 h11
36 sniffio
37 ];
38
39 passthru.optional-dependencies = {
40 http2 = [
41 h2
42 ];
43 socks = [
44 socksio
45 ];
46 };
47
48 nativeCheckInputs = [
49 pproxy
50 pytest-asyncio
51 pytest-httpbin
52 pytest-trio
53 pytestCheckHook
54 ] ++ passthru.optional-dependencies.http2
55 ++ passthru.optional-dependencies.socks;
56
57 pythonImportsCheck = [
58 "httpcore"
59 ];
60
61 preCheck = ''
62 # remove upstreams pytest flags which cause:
63 # httpcore.ConnectError: TLS/SSL connection has been closed (EOF) (_ssl.c:997)
64 rm setup.cfg
65 '';
66
67 pytestFlagsArray = [
68 "--asyncio-mode=strict"
69 ];
70
71 __darwinAllowLocalNetworking = true;
72
73 meta = with lib; {
74 description = "A minimal low-level HTTP client";
75 homepage = "https://github.com/encode/httpcore";
76 license = licenses.bsd3;
77 maintainers = with maintainers; [ ris ];
78 };
79}