summary refs log tree commit diff
path: root/pkgs/development/python-modules/httpx/default.nix
blob: ab5a6820529e7e44f2d0bf1d4956e23290aa35c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{ lib
, brotli
, brotlicffi
, buildPythonPackage
, certifi
, chardet
, click
, fetchFromGitHub
, h2
, httpcore
, isPyPy
, pygments
, python
, pythonOlder
, rfc3986
, rich
, sniffio
, socksio
, pytestCheckHook
, pytest-asyncio
, pytest-trio
, trustme
, uvicorn
}:

buildPythonPackage rec {
  pname = "httpx";
  version = "0.23.0";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "encode";
    repo = pname;
    rev = version;
    hash = "sha256-s11Yeizm3y3w5D6ACQ2wp/KJ0+1ALY/R71IlTP2pMC4=";
  };

  propagatedBuildInputs = [
    certifi
    httpcore
    rfc3986
    sniffio
  ];

  passthru.optional-dependencies = {
    http2 = [
      h2
    ];
    socks = [
      socksio
    ];
    brotli = if isPyPy then [
      brotlicffi
    ] else [
      brotli
    ];
    cli = [
      click
      rich
      pygments
    ];
  };

  checkInputs = [
    chardet
    pytestCheckHook
    pytest-asyncio
    pytest-trio
    trustme
    uvicorn
  ] ++ passthru.optional-dependencies.http2
    ++ passthru.optional-dependencies.brotli
    ++ passthru.optional-dependencies.socks;

  postPatch = ''
    substituteInPlace setup.py \
      --replace "rfc3986[idna2008]>=1.3,<2" "rfc3986>=1.3"
  '';

  # testsuite wants to find installed packages for testing entrypoint
  preCheck = ''
    export PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
  '';

  pytestFlagsArray = [
    "-W"
    "ignore::DeprecationWarning"
  ];

  disabledTests = [
    # httpcore.ConnectError: [Errno 101] Network is unreachable
    "test_connect_timeout"
    # httpcore.ConnectError: [Errno -2] Name or service not known
    "test_async_proxy_close"
    "test_sync_proxy_close"
  ];

  disabledTestPaths = [
    "tests/test_main.py"
  ];

  pythonImportsCheck = [
    "httpx"
  ];

  __darwinAllowLocalNetworking = true;

  meta = with lib; {
    description = "The next generation HTTP client";
    homepage = "https://github.com/encode/httpx";
    license = licenses.bsd3;
    maintainers = with maintainers; [ costrouc fab ];
  };
}