From 3ee400a7e35314d5a110eaddc293d35f23d73151 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 2 Nov 2023 02:17:16 +0100 Subject: [PATCH] python311Packages.urllib3: refactor --- .../python-modules/urllib3/default.nix | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/pkgs/development/python-modules/urllib3/default.nix b/pkgs/development/python-modules/urllib3/default.nix index 34ac36281388..7a374f7c0c2c 100644 --- a/pkgs/development/python-modules/urllib3/default.nix +++ b/pkgs/development/python-modules/urllib3/default.nix @@ -1,4 +1,5 @@ { lib +, backports-zoneinfo , brotli , brotlicffi , buildPythonPackage @@ -8,18 +9,16 @@ , hatchling , idna , isPyPy -, mock , pyopenssl , pysocks -, pytest-freezegun , pytest-timeout , pytestCheckHook -, python-dateutil +, pythonOlder , tornado , trustme }: -buildPythonPackage rec { +let self = buildPythonPackage rec { pname = "urllib3"; version = "2.0.7"; pyproject = true; @@ -33,41 +32,6 @@ buildPythonPackage rec { hatchling ]; - # FIXME: remove backwards compatbility hack - propagatedBuildInputs = passthru.optional-dependencies.brotli - ++ passthru.optional-dependencies.socks; - - nativeCheckInputs = [ - python-dateutil - mock - pytest-freezegun - pytest-timeout - pytestCheckHook - tornado - trustme - ]; - - # Tests in urllib3 are mostly timeout-based instead of event-based and - # are therefore inherently flaky. On your own machine, the tests will - # typically build fine, but on a loaded cluster such as Hydra random - # timeouts will occur. - # - # The urllib3 test suite has two different timeouts in their test suite - # (see `test/__init__.py`): - # - SHORT_TIMEOUT - # - LONG_TIMEOUT - # When CI is in the env, LONG_TIMEOUT will be significantly increased. - # Still, failures can occur and for that reason tests are disabled. - doCheck = false; - - preCheck = '' - export CI # Increases LONG_TIMEOUT - ''; - - pythonImportsCheck = [ - "urllib3" - ]; - passthru.optional-dependencies = { brotli = if isPyPy then [ brotlicffi @@ -86,11 +50,44 @@ buildPythonPackage rec { ]; }; + nativeCheckInputs = [ + pytest-timeout + pytestCheckHook + tornado + trustme + ] ++ lib.optionals (pythonOlder "3.9") [ + backports-zoneinfo + ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); + + # Tests in urllib3 are mostly timeout-based instead of event-based and + # are therefore inherently flaky. On your own machine, the tests will + # typically build fine, but on a loaded cluster such as Hydra random + # timeouts will occur. + # + # The urllib3 test suite has two different timeouts in their test suite + # (see `test/__init__.py`): + # - SHORT_TIMEOUT + # - LONG_TIMEOUT + # When CI is in the env, LONG_TIMEOUT will be significantly increased. + # Still, failures can occur and for that reason tests are disabled. + doCheck = false; + + passthru.tests.pytest = self.overridePythonAttrs (_: { doCheck = true; }); + + preCheck = '' + export CI # Increases LONG_TIMEOUT + ''; + + pythonImportsCheck = [ + "urllib3" + ]; + meta = with lib; { - description = "Powerful, sanity-friendly HTTP client for Python"; - homepage = "https://github.com/shazow/urllib3"; + description = "Powerful, user-friendly HTTP client for Python"; + homepage = "https://github.com/urllib3/urllib3"; changelog = "https://github.com/urllib3/urllib3/blob/${version}/CHANGES.rst"; license = licenses.mit; maintainers = with maintainers; [ fab ]; }; -} +}; +in self