at master 3.2 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 pythonOlder, 6 fetchPypi, 7 fetchpatch, 8 9 # build-system 10 cython, 11 setuptools, 12 13 # native dependencies 14 libuv, 15 16 # tests 17 psutil, 18 pyopenssl, 19 pytestCheckHook, 20}: 21 22buildPythonPackage rec { 23 pname = "uvloop"; 24 version = "0.21.0"; 25 pyproject = true; 26 27 disabled = pythonOlder "3.8"; 28 29 src = fetchPypi { 30 inherit pname version; 31 hash = "sha256-O/ErD9poRHgGp62Ee/pZFhMXcnXTW2ckse5XP6o3BOM="; 32 }; 33 34 patches = [ 35 # fix test failures on Python 3.13 36 # (remove on next update) 37 (fetchpatch { 38 url = "https://github.com/MagicStack/uvloop/commit/96b7ed31afaf02800d779a395591da6a2c8c50e1.patch"; 39 hash = "sha256-Nbe3BuIuwlylll5fIYij+OiP90ZeFNI0GKHK9SwWRk8="; 40 excludes = [ ".github/workflows/tests.yml" ]; 41 }) 42 (fetchpatch { 43 url = "https://github.com/MagicStack/uvloop/commit/56807922f847ddac231a53d5b03eef70092b987c.patch"; 44 hash = "sha256-X5Ob1t/CRy9csw2JrWvwS55G6qTqZhIuGLTy83O03GU="; 45 }) 46 ]; 47 48 postPatch = '' 49 rm -rf vendor 50 51 substituteInPlace setup.py \ 52 --replace-fail "use_system_libuv = False" "use_system_libuv = True" 53 ''; 54 55 build-system = [ 56 cython 57 setuptools 58 ]; 59 60 env.LIBUV_CONFIGURE_HOST = stdenv.hostPlatform.config; 61 62 buildInputs = [ libuv ]; 63 64 nativeCheckInputs = [ 65 pyopenssl 66 pytestCheckHook 67 psutil 68 ]; 69 70 disabledTestPaths = [ 71 # ignore code linting tests 72 "tests/test_sourcecode.py" 73 # Tries to run "env", but fails to find it, even with coreutils provided 74 "tests/test_process.py::Test_UV_Process::test_process_env_2" 75 "tests/test_process.py::Test_AIO_Process::test_process_env_2" 76 # AssertionError: b'' != b'out\n' 77 "tests/test_process.py::Test_UV_Process::test_process_streams_redirect" 78 "tests/test_process.py::Test_AIO_Process::test_process_streams_redirect" 79 # Depends on performance of builder 80 "tests/test_base.py::TestBaseUV.test_call_at" 81 # Pointless and flaky (at least on darwin, depending on the sandbox perhaps) 82 "tests/test_dns.py" 83 ] 84 ++ lib.optionals (pythonOlder "3.11") [ 85 "tests/test_tcp.py::Test_UV_TCPSSL::test_create_connection_ssl_failed_certificat" 86 ] 87 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ 88 # Segmentation fault 89 "tests/test_fs_event.py::Test_UV_FS_EVENT_RENAME::test_fs_event_rename" 90 # Broken: https://github.com/NixOS/nixpkgs/issues/160904 91 "tests/test_context.py::Test_UV_Context::test_create_ssl_server_manual_connection_lost" 92 ]; 93 94 preCheck = '' 95 # force using installed/compiled uvloop 96 rm -rf uvloop 97 '' 98 + lib.optionalString stdenv.hostPlatform.isDarwin '' 99 # Work around "OSError: AF_UNIX path too long" 100 # https://github.com/MagicStack/uvloop/issues/463 101 export TMPDIR="/tmp" 102 ''; 103 104 pythonImportsCheck = [ 105 "uvloop" 106 "uvloop.loop" 107 ]; 108 109 # Some of the tests use localhost networking. 110 __darwinAllowLocalNetworking = true; 111 112 meta = with lib; { 113 changelog = "https://github.com/MagicStack/uvloop/releases/tag/v${version}"; 114 description = "Fast implementation of asyncio event loop on top of libuv"; 115 homepage = "https://github.com/MagicStack/uvloop"; 116 license = licenses.mit; 117 maintainers = [ ]; 118 }; 119}