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