nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, async_generator
3, buildPythonPackage
4, pythonOlder
5, fetchFromGitHub
6, certifi
7, charset-normalizer
8, httpcore
9, rfc3986
10, sniffio
11, h2
12, socksio
13, isPyPy
14, brotli
15, brotlicffi
16, click
17, rich
18, pygments
19, python
20, pytestCheckHook
21, pytest-asyncio
22, pytest-trio
23, typing-extensions
24, trustme
25, uvicorn
26}:
27
28buildPythonPackage rec {
29 pname = "httpx";
30 version = "0.22.0";
31 format = "setuptools";
32
33 disabled = pythonOlder "3.6";
34
35 src = fetchFromGitHub {
36 owner = "encode";
37 repo = pname;
38 rev = version;
39 sha256 = "sha256-hQmQodGpVG23IZSsWV7rB1iB6QAudDao/8YshIgpmas=";
40 };
41
42 propagatedBuildInputs = [
43 certifi
44 charset-normalizer
45 httpcore
46 rfc3986
47 sniffio
48 ] ++ lib.optionals (pythonOlder "3.7") [
49 async_generator
50 ];
51
52 passthru.optional-dependencies = {
53 http2 = [ h2 ];
54 socks = [ socksio ];
55 brotli = if isPyPy then [ brotlicffi ] else [ brotli ];
56 cli = [ click rich pygments ];
57 };
58
59 checkInputs = [
60 pytestCheckHook
61 pytest-asyncio
62 pytest-trio
63 trustme
64 typing-extensions
65 uvicorn
66 ] ++ passthru.optional-dependencies.http2
67 ++ passthru.optional-dependencies.brotli
68 ++ passthru.optional-dependencies.socks;
69
70 postPatch = ''
71 substituteInPlace setup.py \
72 --replace "rfc3986[idna2008]>=1.3,<2" "rfc3986>=1.3"
73 '';
74
75 # testsuite wants to find installed packages for testing entrypoint
76 preCheck = ''
77 export PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
78 '';
79
80 pytestFlagsArray = [
81 "-W"
82 "ignore::DeprecationWarning"
83 ];
84
85 disabledTests = [
86 # httpcore.ConnectError: [Errno 101] Network is unreachable
87 "test_connect_timeout"
88 # httpcore.ConnectError: [Errno -2] Name or service not known
89 "test_async_proxy_close"
90 "test_sync_proxy_close"
91 # sensitive to charset_normalizer output
92 "iso-8859-1"
93 "test_response_no_charset_with_iso_8859_1_content"
94 ];
95
96 disabledTestPaths = [
97 "tests/test_main.py"
98 ];
99
100 pythonImportsCheck = [
101 "httpx"
102 ];
103
104 __darwinAllowLocalNetworking = true;
105
106 meta = with lib; {
107 description = "The next generation HTTP client";
108 homepage = "https://github.com/encode/httpx";
109 license = licenses.bsd3;
110 maintainers = with maintainers; [ costrouc fab ];
111 };
112}