at 23.05-pre 3.4 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, pythonOlder 5, fetchPypi 6, cython 7, libuv 8, CoreServices 9, ApplicationServices 10 11# Check Inputs 12, aiohttp 13, psutil 14, pyopenssl 15, pytestCheckHook 16}: 17 18buildPythonPackage rec { 19 pname = "uvloop"; 20 version = "0.17.0"; 21 format = "setuptools"; 22 disabled = pythonOlder "3.7"; 23 24 src = fetchPypi { 25 inherit pname version; 26 hash = "sha256-Dd9rr5zxGhoixxSH858Vss9461vefltF+7meip2RueE="; 27 }; 28 29 nativeBuildInputs = [ 30 cython 31 ]; 32 33 buildInputs = [ 34 libuv 35 ] ++ lib.optionals stdenv.isDarwin [ 36 CoreServices 37 ApplicationServices 38 ]; 39 40 dontUseSetuptoolsCheck = true; 41 checkInputs = [ 42 pytestCheckHook 43 psutil 44 ] ++ lib.optionals (pythonOlder "3.11") [ 45 aiohttp 46 ]; 47 48 LIBUV_CONFIGURE_HOST = stdenv.hostPlatform.config; 49 50 pytestFlagsArray = [ 51 # from pytest.ini, these are NECESSARY to prevent failures 52 "--capture=no" 53 "--assert=plain" 54 "--strict" 55 "--tb=native" 56 # Depend on pyopenssl 57 "--deselect=tests/test_tcp.py::Test_UV_TCPSSL::test_flush_before_shutdown" 58 "--deselect=tests/test_tcp.py::Test_UV_TCPSSL::test_renegotiation" 59 # test gets stuck in epoll_pwait on hydras aarch64 builders 60 # https://github.com/MagicStack/uvloop/issues/412 61 "--deselect=tests/test_tcp.py::Test_AIO_TCPSSL::test_remote_shutdown_receives_trailing_data" 62 # Tries to import cythonized file for which the .pyx file is not shipped via PyPi 63 "--deselect=tests/test_libuv_api.py::Test_UV_libuv::test_libuv_get_loop_t_ptr" 64 # Tries to run "env", but fails to find it 65 "--deselect=tests/test_process.py::Test_UV_Process::test_process_env_2" 66 "--deselect=tests/test_process.py::Test_AIO_Process::test_process_env_2" 67 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ 68 # Flaky test: https://github.com/MagicStack/uvloop/issues/412 69 "--deselect=tests/test_tcp.py::Test_UV_TCPSSL::test_shutdown_timeout_handler_not_set" 70 # Broken: https://github.com/NixOS/nixpkgs/issues/160904 71 "--deselect=tests/test_context.py::Test_UV_Context::test_create_ssl_server_manual_connection_lost" 72 # Flaky test: https://github.com/MagicStack/uvloop/issues/513 73 "--deselect=tests/test_tcp.py::Test_UV_TCP::test_create_server_5" 74 "--deselect=tests/test_tcp.py::Test_UV_TCP::test_create_server_6" 75 ]; 76 77 disabledTestPaths = [ 78 # ignore code linting tests 79 "tests/test_sourcecode.py" 80 ]; 81 82 preCheck = lib.optionalString stdenv.isDarwin '' 83 # Work around "OSError: AF_UNIX path too long" 84 # https://github.com/MagicStack/uvloop/issues/463 85 export TMPDIR="/tmp" 86 '' + '' 87 # pyopenssl is not well supported by upstream 88 # https://github.com/NixOS/nixpkgs/issues/175875 89 substituteInPlace tests/test_tcp.py \ 90 --replace "from OpenSSL import SSL as openssl_ssl" "" 91 # force using installed/compiled uvloop vs source by moving tests to temp dir 92 export TEST_DIR=$(mktemp -d) 93 cp -r tests $TEST_DIR 94 pushd $TEST_DIR 95 ''; 96 97 postCheck = '' 98 popd 99 ''; 100 101 pythonImportsCheck = [ 102 "uvloop" 103 "uvloop.loop" 104 ]; 105 106 # Some of the tests use localhost networking. 107 __darwinAllowLocalNetworking = true; 108 109 meta = with lib; { 110 description = "Fast implementation of asyncio event loop on top of libuv"; 111 homepage = "https://github.com/MagicStack/uvloop"; 112 license = licenses.mit; 113 maintainers = with maintainers; [ costrouc ]; 114 }; 115}