1{ lib
2, brotli
3, brotlicffi
4, buildPythonPackage
5, certifi
6, chardet
7, charset-normalizer
8, fetchPypi
9, idna
10, pytest-mock
11, pytest-xdist
12, pytestCheckHook
13, urllib3
14, isPy27
15, isPy3k
16, trustme
17}:
18
19buildPythonPackage rec {
20 pname = "requests";
21 version = "2.26.0";
22
23 src = fetchPypi {
24 inherit pname version;
25 sha256 = "sha256-uKpY+M95P/2HgtPYyxnmbvNverpDU+7IWedGeLAbB6c=";
26 };
27
28 patches = [
29 # Use the default NixOS CA bundle from the certifi package
30 ./0001-Prefer-NixOS-Nix-default-CA-bundles-over-certifi.patch
31 ];
32
33 postPatch = ''
34 # Use latest idna
35 substituteInPlace setup.py --replace ",<3" ""
36 '';
37
38 propagatedBuildInputs = [
39 certifi
40 idna
41 urllib3
42 chardet
43 ] ++ lib.optionals (isPy3k) [
44 brotlicffi
45 charset-normalizer
46 ] ++ lib.optionals (isPy27) [
47 brotli
48 ];
49
50 checkInputs = [
51 pytest-mock
52 pytest-xdist
53 pytestCheckHook
54 trustme
55 ];
56
57 # AttributeError: 'KeywordMapping' object has no attribute 'get'
58 doCheck = !isPy27;
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 ];
75
76 pythonImportsCheck = [ "requests" ];
77
78 meta = with lib; {
79 description = "Simple HTTP library for Python";
80 homepage = "http://docs.python-requests.org/en/latest/";
81 license = licenses.asl20;
82 maintainers = with maintainers; [ fab ];
83 };
84}