1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 certifi,
6 chardet,
7 charset-normalizer,
8 fetchFromGitHub,
9 idna,
10 pysocks,
11 pytest-mock,
12 pytest-xdist,
13 pytestCheckHook,
14 pythonOlder,
15 setuptools,
16 urllib3,
17}:
18
19buildPythonPackage rec {
20 pname = "requests";
21 version = "2.32.4";
22 pyproject = true;
23
24 disabled = pythonOlder "3.8";
25
26 __darwinAllowLocalNetworking = true;
27
28 src = fetchFromGitHub {
29 owner = "psf";
30 repo = "requests";
31 tag = "v${version}";
32 hash = "sha256-sD9GLCAa3y9L1J+fcd+ZXBtW4jNL40hOesKXORhcjGQ=";
33 };
34
35 patches = [
36 # https://github.com/psf/requests/issues/6730
37 # https://github.com/psf/requests/pull/6731
38 ./ca-load-regression.patch
39 ];
40
41 build-system = [ setuptools ];
42
43 dependencies = [
44 certifi
45 charset-normalizer
46 idna
47 urllib3
48 ];
49
50 optional-dependencies = {
51 security = [ ];
52 socks = [ pysocks ];
53 use_chardet_on_py3 = [ chardet ];
54 };
55
56 nativeCheckInputs = [
57 pytest-mock
58 pytest-xdist
59 pytestCheckHook
60 ]
61 ++ optional-dependencies.socks;
62
63 disabledTests = [
64 # Disable tests that require network access and use httpbin
65 "requests.api.request"
66 "requests.models.PreparedRequest"
67 "requests.sessions.Session"
68 "requests"
69 "test_redirecting_to_bad_url"
70 "test_requests_are_updated_each_time"
71 "test_should_bypass_proxies_pass_only_hostname"
72 "test_urllib3_pool_connection_closed"
73 "test_urllib3_retries"
74 "test_use_proxy_from_environment"
75 "TestRequests"
76 "TestTimeout"
77 ]
78 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
79 # Fatal Python error: Aborted
80 "test_basic_response"
81 "test_text_response"
82 ];
83
84 disabledTestPaths = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
85 # Fatal Python error: Aborted
86 "tests/test_lowlevel.py"
87 ];
88
89 pythonImportsCheck = [ "requests" ];
90
91 meta = with lib; {
92 description = "HTTP library for Python";
93 homepage = "http://docs.python-requests.org/";
94 changelog = "https://github.com/psf/requests/blob/v${version}/HISTORY.md";
95 license = licenses.asl20;
96 maintainers = with maintainers; [ fab ];
97 };
98}