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