nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, brotli
4, brotlicffi
5, buildPythonPackage
6, certifi
7, chardet
8, charset-normalizer
9, fetchPypi
10, idna
11, isPy27
12, isPy3k
13, pysocks
14, pytest-mock
15, pytest-xdist
16, pytestCheckHook
17, urllib3
18}:
19
20buildPythonPackage rec {
21 pname = "requests";
22 version = "2.27.1";
23
24 src = fetchPypi {
25 inherit pname version;
26 hash = "sha256-aNfFb9WomZiHco7zBKbRLtx7508c+kdxT8i0FFJcmmE=";
27 };
28
29 patches = [
30 # Use the default NixOS CA bundle from the certifi package
31 ./0001-Prefer-NixOS-Nix-default-CA-bundles-over-certifi.patch
32 ];
33
34 propagatedBuildInputs = [
35 certifi
36 idna
37 urllib3
38 chardet
39 ] ++ lib.optionals isPy3k [
40 brotlicffi
41 charset-normalizer
42 ] ++ lib.optionals isPy27 [
43 brotli
44 ];
45
46 checkInputs = [
47 pysocks
48 pytest-mock
49 pytest-xdist
50 pytestCheckHook
51 ];
52
53 # AttributeError: 'KeywordMapping' object has no attribute 'get'
54 doCheck = !isPy27;
55
56 disabledTests = [
57 # Disable tests that require network access and use httpbin
58 "requests.api.request"
59 "requests.models.PreparedRequest"
60 "requests.sessions.Session"
61 "requests"
62 "test_redirecting_to_bad_url"
63 "test_requests_are_updated_each_time"
64 "test_should_bypass_proxies_pass_only_hostname"
65 "test_urllib3_pool_connection_closed"
66 "test_urllib3_retries"
67 "test_use_proxy_from_environment"
68 "TestRequests"
69 "TestTimeout"
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 = [
82 "requests"
83 ];
84
85 meta = with lib; {
86 description = "HTTP library for Python";
87 homepage = "http://docs.python-requests.org/";
88 license = licenses.asl20;
89 maintainers = with maintainers; [ fab ];
90 };
91}