1{ lib
2, brotli
3, brotlicffi
4, buildPythonPackage
5, certifi
6, cryptography
7, fetchpatch
8, fetchPypi
9, idna
10, isPyPy
11, mock
12, pyopenssl
13, pysocks
14, pytest-freezegun
15, pytest-timeout
16, pytestCheckHook
17, python-dateutil
18, tornado
19, trustme
20}:
21
22buildPythonPackage rec {
23 pname = "urllib3";
24 version = "1.26.18";
25 format = "setuptools";
26
27 src = fetchPypi {
28 inherit pname version;
29 hash = "sha256-+OzBu6VmdBNFfFKauVW/jGe0XbeZ0VkGYmFxnjKFgKA=";
30 };
31
32 patches = [
33 (fetchpatch {
34 name = "revert-threadsafe-poolmanager.patch";
35 url = "https://github.com/urllib3/urllib3/commit/710114d7810558fd7e224054a566b53bb8601494.patch";
36 revert = true;
37 hash = "sha256-2O0y0Tij1QF4Hx5r+WMxIHDpXTBHign61AXLzsScrGo=";
38 })
39 ];
40
41 # FIXME: remove backwards compatbility hack
42 propagatedBuildInputs = passthru.optional-dependencies.brotli
43 ++ passthru.optional-dependencies.socks;
44
45 nativeCheckInputs = [
46 python-dateutil
47 mock
48 pytest-freezegun
49 pytest-timeout
50 pytestCheckHook
51 tornado
52 trustme
53 ];
54
55 # Tests in urllib3 are mostly timeout-based instead of event-based and
56 # are therefore inherently flaky. On your own machine, the tests will
57 # typically build fine, but on a loaded cluster such as Hydra random
58 # timeouts will occur.
59 #
60 # The urllib3 test suite has two different timeouts in their test suite
61 # (see `test/__init__.py`):
62 # - SHORT_TIMEOUT
63 # - LONG_TIMEOUT
64 # When CI is in the env, LONG_TIMEOUT will be significantly increased.
65 # Still, failures can occur and for that reason tests are disabled.
66 doCheck = false;
67
68 preCheck = ''
69 export CI # Increases LONG_TIMEOUT
70 '';
71
72 pythonImportsCheck = [
73 "urllib3"
74 ];
75
76 passthru.optional-dependencies = {
77 brotli = if isPyPy then [
78 brotlicffi
79 ] else [
80 brotli
81 ];
82 # Use carefully since pyopenssl is not supported aarch64-darwin
83 secure = [
84 certifi
85 cryptography
86 idna
87 pyopenssl
88 ];
89 socks = [
90 pysocks
91 ];
92 };
93
94 meta = with lib; {
95 description = "Powerful, sanity-friendly HTTP client for Python";
96 homepage = "https://github.com/shazow/urllib3";
97 changelog = "https://github.com/urllib3/urllib3/blob/${version}/CHANGES.rst";
98 license = licenses.mit;
99 maintainers = with maintainers; [ fab ];
100 };
101}