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.5";
28 pyproject = true;
29
30 disabled = pythonOlder "3.8";
31
32 src = fetchFromGitHub {
33 owner = "encode";
34 repo = "httpcore";
35 rev = "refs/tags/${version}";
36 hash = "sha256-05jYLrBiPRg1qQEz8mRvYJKHFsfneh7z9yHIXuYYa5o=";
37 };
38
39 nativeBuildInputs = [
40 hatchling
41 hatch-fancy-pypi-readme
42 ];
43
44 propagatedBuildInputs = [
45 certifi
46 h11
47 ];
48
49 passthru.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 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
63
64 pythonImportsCheck = [ "httpcore" ];
65
66 __darwinAllowLocalNetworking = true;
67
68 passthru.tests = {
69 inherit httpx httpx-socks respx;
70 };
71
72 meta = with lib; {
73 changelog = "https://github.com/encode/httpcore/blob/${version}/CHANGELOG.md";
74 description = "Minimal low-level HTTP client";
75 homepage = "https://github.com/encode/httpcore";
76 license = licenses.bsd3;
77 maintainers = with maintainers; [ ris ];
78 };
79}