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 dependencies = [
34 brotlicffi
35 certifi
36 charset-normalizer
37 idna
38 urllib3
39 ];
40
41 optional-dependencies = {
42 security = [ ];
43 socks = [ pysocks ];
44 use_chardet_on_py3 = [ chardet ];
45 };
46
47 nativeCheckInputs = [
48 pytest-mock
49 pytest-xdist
50 pytestCheckHook
51 ] ++ optional-dependencies.socks;
52
53 disabledTests =
54 [
55 # Disable tests that require network access and use httpbin
56 "requests.api.request"
57 "requests.models.PreparedRequest"
58 "requests.sessions.Session"
59 "requests"
60 "test_redirecting_to_bad_url"
61 "test_requests_are_updated_each_time"
62 "test_should_bypass_proxies_pass_only_hostname"
63 "test_urllib3_pool_connection_closed"
64 "test_urllib3_retries"
65 "test_use_proxy_from_environment"
66 "TestRequests"
67 "TestTimeout"
68 ]
69 ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
70 # Fatal Python error: Aborted
71 "test_basic_response"
72 "test_text_response"
73 ];
74
75 disabledTestPaths = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
76 # Fatal Python error: Aborted
77 "tests/test_lowlevel.py"
78 ];
79
80 pythonImportsCheck = [ "requests" ];
81
82 meta = with lib; {
83 description = "HTTP library for Python";
84 homepage = "http://docs.python-requests.org/";
85 changelog = "https://github.com/psf/requests/blob/v${version}/HISTORY.md";
86 license = licenses.asl20;
87 maintainers = with maintainers; [ fab ];
88 };
89}