1{
2 lib,
3 anyio,
4 buildPythonPackage,
5 certifi,
6 fetchFromGitHub,
7 hatchling,
8 hatch-fancy-pypi-readme,
9 h11,
10 h2,
11 pproxy,
12 pytest-asyncio,
13 pytest-httpbin,
14 pytest-trio,
15 pytestCheckHook,
16 pythonOlder,
17 socksio,
18 trio,
19 # for passthru.tests
20 httpx,
21 httpx-socks,
22 respx,
23}:
24
25buildPythonPackage rec {
26 pname = "httpcore";
27 version = "1.0.9";
28 pyproject = true;
29
30 disabled = pythonOlder "3.8";
31
32 src = fetchFromGitHub {
33 owner = "encode";
34 repo = "httpcore";
35 tag = version;
36 hash = "sha256-YtAbx0iXN7u8pMBXQBUydvAH6ilH+veklvxSh5EVFXo=";
37 };
38
39 build-system = [
40 hatchling
41 hatch-fancy-pypi-readme
42 ];
43
44 dependencies = [
45 certifi
46 h11
47 ];
48
49 optional-dependencies = {
50 asyncio = [ anyio ];
51 http2 = [ h2 ];
52 socks = [ socksio ];
53 trio = [ trio ];
54 };
55
56 nativeCheckInputs = [
57 pproxy
58 pytest-asyncio
59 pytest-httpbin
60 pytest-trio
61 pytestCheckHook
62 ]
63 ++ lib.flatten (builtins.attrValues optional-dependencies);
64
65 pythonImportsCheck = [ "httpcore" ];
66
67 __darwinAllowLocalNetworking = true;
68
69 passthru.tests = {
70 inherit httpx httpx-socks respx;
71 };
72
73 meta = with lib; {
74 changelog = "https://github.com/encode/httpcore/blob/${version}/CHANGELOG.md";
75 description = "Minimal low-level HTTP client";
76 homepage = "https://github.com/encode/httpcore";
77 license = licenses.bsd3;
78 maintainers = with maintainers; [ ris ];
79 };
80}