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