1{
2 lib,
3 stdenv,
4 brotlicffi,
5 buildPythonPackage,
6 certifi,
7 chardet,
8 charset-normalizer,
9 fetchPypi,
10 idna,
11 pysocks,
12 pytest-mock,
13 pytest-xdist,
14 pytestCheckHook,
15 pythonOlder,
16 urllib3,
17}:
18
19buildPythonPackage rec {
20 pname = "requests";
21 version = "2.32.3";
22 format = "setuptools";
23
24 disabled = pythonOlder "3.7";
25
26 __darwinAllowLocalNetworking = true;
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-VTZUF3NOsYJVWQqf+euX6eHaho1MzWQCOZ6vaK8gp2A=";
31 };
32
33 patches = [
34 # https://github.com/psf/requests/issues/6730
35 # https://github.com/psf/requests/pull/6731
36 ./ca-load-regression.patch
37 ];
38
39 dependencies = [
40 brotlicffi
41 certifi
42 charset-normalizer
43 idna
44 urllib3
45 ];
46
47 optional-dependencies = {
48 security = [ ];
49 socks = [ pysocks ];
50 use_chardet_on_py3 = [ chardet ];
51 };
52
53 nativeCheckInputs = [
54 pytest-mock
55 pytest-xdist
56 pytestCheckHook
57 ] ++ optional-dependencies.socks;
58
59 disabledTests =
60 [
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 ]
75 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
76 # Fatal Python error: Aborted
77 "test_basic_response"
78 "test_text_response"
79 ];
80
81 disabledTestPaths = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
82 # Fatal Python error: Aborted
83 "tests/test_lowlevel.py"
84 ];
85
86 pythonImportsCheck = [ "requests" ];
87
88 meta = with lib; {
89 description = "HTTP library for Python";
90 homepage = "http://docs.python-requests.org/";
91 changelog = "https://github.com/psf/requests/blob/v${version}/HISTORY.md";
92 license = licenses.asl20;
93 maintainers = with maintainers; [ fab ];
94 };
95}