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.14";
24 format = "setuptools";
25
26 src = fetchPypi {
27 inherit pname version;
28 hash = "sha256-B2kHv4/TVc3ndyhHExZiWk0vfnE8El9RlTu1s+7PT3I=";
29 };
30
31 # FIXME: remove backwards compatbility hack
32 propagatedBuildInputs = passthru.optional-dependencies.brotli
33 ++ passthru.optional-dependencies.socks;
34
35 nativeCheckInputs = [
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 [
68 brotlicffi
69 ] else [
70 brotli
71 ];
72 # Use carefully since pyopenssl is not supported aarch64-darwin
73 secure = [
74 certifi
75 cryptography
76 idna
77 pyopenssl
78 ];
79 socks = [
80 pysocks
81 ];
82 };
83
84 meta = with lib; {
85 description = "Powerful, sanity-friendly HTTP client for Python";
86 homepage = "https://github.com/shazow/urllib3";
87 changelog = "https://github.com/urllib3/urllib3/blob/${version}/CHANGES.rst";
88 license = licenses.mit;
89 maintainers = with maintainers; [ fab ];
90 };
91}