at 24.05-pre 2.4 kB view raw
1{ lib 2, stdenv 3, brotli 4, brotlicffi 5, buildPythonPackage 6, certifi 7, chardet 8, click 9, fetchFromGitHub 10, h2 11, hatch-fancy-pypi-readme 12, hatchling 13, httpcore 14, isPyPy 15, multipart 16, pygments 17, python 18, pythonOlder 19, rfc3986 20, rich 21, sniffio 22, socksio 23, pytestCheckHook 24, pytest-asyncio 25, pytest-trio 26, trustme 27, uvicorn 28}: 29 30buildPythonPackage rec { 31 pname = "httpx"; 32 version = "0.25.0"; 33 format = "pyproject"; 34 35 disabled = pythonOlder "3.7"; 36 37 src = fetchFromGitHub { 38 owner = "encode"; 39 repo = pname; 40 rev = "refs/tags/${version}"; 41 hash = "sha256-zQVavjU66ksO0FB1h32e0YUhOGiQ4jHPvjgLhtxjU6s="; 42 }; 43 44 nativeBuildInputs = [ 45 hatch-fancy-pypi-readme 46 hatchling 47 ]; 48 49 propagatedBuildInputs = [ 50 certifi 51 httpcore 52 rfc3986 53 sniffio 54 ]; 55 56 passthru.optional-dependencies = { 57 http2 = [ 58 h2 59 ]; 60 socks = [ 61 socksio 62 ]; 63 brotli = if isPyPy then [ 64 brotlicffi 65 ] else [ 66 brotli 67 ]; 68 cli = [ 69 click 70 rich 71 pygments 72 ]; 73 }; 74 75 # trustme uses pyopenssl 76 doCheck = !(stdenv.isDarwin && stdenv.isAarch64); 77 78 nativeCheckInputs = [ 79 chardet 80 multipart 81 pytestCheckHook 82 pytest-asyncio 83 pytest-trio 84 trustme 85 uvicorn 86 ] ++ passthru.optional-dependencies.http2 87 ++ passthru.optional-dependencies.brotli 88 ++ passthru.optional-dependencies.socks; 89 90 postPatch = '' 91 substituteInPlace pyproject.toml \ 92 --replace "rfc3986[idna2008]>=1.3,<2" "rfc3986>=1.3" 93 ''; 94 95 # testsuite wants to find installed packages for testing entrypoint 96 preCheck = '' 97 export PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH 98 ''; 99 100 pytestFlagsArray = [ 101 "-W" "ignore::DeprecationWarning" 102 "-W" "ignore::trio.TrioDeprecationWarning" 103 ]; 104 105 disabledTests = [ 106 # httpcore.ConnectError: [Errno 101] Network is unreachable 107 "test_connect_timeout" 108 # httpcore.ConnectError: [Errno -2] Name or service not known 109 "test_async_proxy_close" 110 "test_sync_proxy_close" 111 ]; 112 113 disabledTestPaths = [ 114 "tests/test_main.py" 115 ]; 116 117 pythonImportsCheck = [ 118 "httpx" 119 ]; 120 121 __darwinAllowLocalNetworking = true; 122 123 meta = with lib; { 124 changelog = "https://github.com/encode/httpx/blob/${src.rev}/CHANGELOG.md"; 125 description = "The next generation HTTP client"; 126 homepage = "https://github.com/encode/httpx"; 127 license = licenses.bsd3; 128 maintainers = with maintainers; [ fab ]; 129 }; 130}