1{ lib 2, stdenv 3, brotlicffi 4, buildPythonPackage 5, certifi 6, chardet 7, charset-normalizer 8, fetchPypi 9, idna 10, pysocks 11, pytest-mock 12, pytest-xdist 13, pytestCheckHook 14, pythonOlder 15, urllib3 16}: 17 18buildPythonPackage rec { 19 pname = "requests"; 20 version = "2.28.1"; 21 disabled = pythonOlder "3.7"; 22 23 __darwinAllowLocalNetworking = true; 24 25 src = fetchPypi { 26 inherit pname version; 27 hash = "sha256-fFWZsQL+3apmHIJsVqtP7ii/0X9avKHrvj5/GdfJeYM="; 28 }; 29 30 patches = [ 31 # Use the default NixOS CA bundle from the certifi package 32 ./0001-Prefer-NixOS-Nix-default-CA-bundles-over-certifi.patch 33 ]; 34 35 propagatedBuildInputs = [ 36 brotlicffi 37 certifi 38 charset-normalizer 39 idna 40 urllib3 41 ]; 42 43 passthru.optional-dependencies = { 44 security = []; 45 socks = [ 46 pysocks 47 ]; 48 use_chardet_on_py3 = [ 49 chardet 50 ]; 51 }; 52 53 checkInputs = [ 54 pytest-mock 55 pytest-xdist 56 pytestCheckHook 57 ] 58 ++ passthru.optional-dependencies.socks; 59 60 disabledTests = [ 61 # Disable tests that require network access and use httpbin 62 "requests.api.request" 63 "requests.models.PreparedRequest" 64 "requests.sessions.Session" 65 "requests" 66 "test_redirecting_to_bad_url" 67 "test_requests_are_updated_each_time" 68 "test_should_bypass_proxies_pass_only_hostname" 69 "test_urllib3_pool_connection_closed" 70 "test_urllib3_retries" 71 "test_use_proxy_from_environment" 72 "TestRequests" 73 "TestTimeout" 74 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ 75 # Fatal Python error: Aborted 76 "test_basic_response" 77 "test_text_response" 78 ]; 79 80 disabledTestPaths = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ 81 # Fatal Python error: Aborted 82 "tests/test_lowlevel.py" 83 ]; 84 85 pythonImportsCheck = [ 86 "requests" 87 ]; 88 89 meta = with lib; { 90 description = "HTTP library for Python"; 91 homepage = "http://docs.python-requests.org/"; 92 license = licenses.asl20; 93 maintainers = with maintainers; [ fab ]; 94 }; 95}