at master 2.1 kB view raw
1{ 2 stdenv, 3 lib, 4 buildPythonPackage, 5 fetchFromGitHub, 6 setuptools, 7 curl-impersonate-chrome, 8 cffi, 9 certifi, 10 charset-normalizer, 11 cryptography, 12 fastapi, 13 httpx, 14 proxy-py, 15 pytest-asyncio, 16 pytest-trio, 17 pytestCheckHook, 18 python-multipart, 19 trustme, 20 uvicorn, 21 websockets, 22 writableTmpDirAsHomeHook, 23}: 24 25buildPythonPackage rec { 26 pname = "curl-cffi"; 27 version = "0.12.0"; 28 pyproject = true; 29 30 src = fetchFromGitHub { 31 owner = "lexiforest"; 32 repo = "curl_cffi"; 33 tag = "v${version}"; 34 hash = "sha256-VE/b1Cs/wpZlu7lOURT/QfP7DuNudD441zG603LT4LM="; 35 }; 36 37 patches = [ ./use-system-libs.patch ]; 38 buildInputs = [ curl-impersonate-chrome ]; 39 40 build-system = [ 41 cffi 42 setuptools 43 ]; 44 45 dependencies = [ 46 cffi 47 certifi 48 ]; 49 50 env = lib.optionalAttrs stdenv.cc.isGNU { 51 NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types"; 52 }; 53 54 pythonImportsCheck = [ "curl_cffi" ]; 55 56 nativeCheckInputs = [ 57 charset-normalizer 58 cryptography 59 fastapi 60 httpx 61 proxy-py 62 pytest-asyncio 63 pytest-trio 64 pytestCheckHook 65 python-multipart 66 trustme 67 uvicorn 68 websockets 69 writableTmpDirAsHomeHook 70 ]; 71 72 preCheck = '' 73 # import from $out 74 rm -r curl_cffi 75 ''; 76 77 enabledTestPaths = [ 78 "tests/unittest" 79 ]; 80 81 disabledTestPaths = [ 82 # test accesses network 83 "tests/unittest/test_smoke.py::test_async" 84 ]; 85 86 disabledTests = [ 87 # FIXME ImpersonateError: Impersonating chrome136 is not supported 88 "test_impersonate_without_version" 89 "test_with_impersonate" 90 # InvalidURL: Invalid URL component 'path' 91 "test_update_params" 92 # tests access network 93 "test_add_handle" 94 "test_socket_action" 95 "test_without_impersonate" 96 ]; 97 98 __darwinAllowLocalNetworking = true; 99 100 meta = with lib; { 101 changelog = "https://github.com/lexiforest/curl_cffi/releases/tag/${src.tag}"; 102 description = "Python binding for curl-impersonate via cffi"; 103 homepage = "https://curl-cffi.readthedocs.io"; 104 license = licenses.mit; 105 maintainers = with maintainers; [ chuangzhu ]; 106 }; 107}