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