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