1{ lib
2, anyio
3, buildPythonPackage
4, certifi
5, fetchFromGitHub
6, hatchling
7, hatch-fancy-pypi-readme
8, h11
9, h2
10, pproxy
11, pytest-asyncio
12, pytest-httpbin
13, pytest-trio
14, pytestCheckHook
15, pythonOlder
16, sniffio
17, socksio
18# for passthru.tests
19, httpx
20, httpx-socks
21}:
22
23buildPythonPackage rec {
24 pname = "httpcore";
25 version = "0.18.0";
26 format = "pyproject";
27
28 disabled = pythonOlder "3.7";
29
30 src = fetchFromGitHub {
31 owner = "encode";
32 repo = pname;
33 rev = "refs/tags/${version}";
34 hash = "sha256-UEpERsB7jZlMqRtyHxLYBisfDbTGaAiTtsgU1WUpvtA=";
35 };
36
37 nativeBuildInputs = [
38 hatchling
39 hatch-fancy-pypi-readme
40 ];
41
42 propagatedBuildInputs = [
43 anyio
44 certifi
45 h11
46 sniffio
47 ];
48
49 passthru.optional-dependencies = {
50 http2 = [
51 h2
52 ];
53 socks = [
54 socksio
55 ];
56 };
57
58 nativeCheckInputs = [
59 pproxy
60 pytest-asyncio
61 pytest-httpbin
62 pytest-trio
63 pytestCheckHook
64 ] ++ passthru.optional-dependencies.http2
65 ++ passthru.optional-dependencies.socks;
66
67 disabledTests = [
68 # https://github.com/encode/httpcore/discussions/813
69 "test_connection_pool_timeout_during_request"
70 "test_connection_pool_timeout_during_response"
71 "test_h11_timeout_during_request"
72 "test_h11_timeout_during_response"
73 "test_h2_timeout_during_handshake"
74 "test_h2_timeout_during_request"
75 "test_h2_timeout_during_response"
76 ];
77
78 pythonImportsCheck = [
79 "httpcore"
80 ];
81
82 __darwinAllowLocalNetworking = true;
83
84 passthru.tests = {
85 inherit httpx httpx-socks;
86 };
87
88 meta = with lib; {
89 changelog = "https://github.com/encode/httpcore/releases/tag/${version}";
90 description = "A minimal low-level HTTP client";
91 homepage = "https://github.com/encode/httpcore";
92 license = licenses.bsd3;
93 maintainers = with maintainers; [ ris ];
94 };
95}