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