1{ lib
2, stdenv
3, buildPythonPackage
4, pythonOlder
5, fetchPypi
6
7# build-system
8, cython
9, setuptools
10
11# native dependencies
12, libuv
13, CoreServices
14, ApplicationServices
15
16# tests
17, aiohttp
18, psutil
19, pyopenssl
20, pytestCheckHook
21}:
22
23buildPythonPackage rec {
24 pname = "uvloop";
25 version = "0.19.0";
26 pyproject = true;
27
28 disabled = pythonOlder "3.8";
29
30 src = fetchPypi {
31 inherit pname version;
32 hash = "sha256-Akb0/Rvyv3AuBrDUXukWd+5cMSQvOaq06m/gxRrt0P0=";
33 };
34
35 nativeBuildInputs = [
36 cython
37 setuptools
38 ];
39
40 env.LIBUV_CONFIGURE_HOST = stdenv.hostPlatform.config;
41
42 buildInputs = [
43 libuv
44 ] ++ lib.optionals stdenv.isDarwin [
45 CoreServices
46 ApplicationServices
47 ];
48
49 nativeCheckInputs = [
50 aiohttp
51 pyopenssl
52 pytestCheckHook
53 psutil
54 ];
55
56 pytestFlagsArray = [
57 # Tries to run "env", but fails to find it, even with coreutils provided
58 "--deselect=tests/test_process.py::Test_UV_Process::test_process_env_2"
59 "--deselect=tests/test_process.py::Test_AIO_Process::test_process_env_2"
60 # AssertionError: b'' != b'out\n'
61 "--deselect=tests/test_process.py::Test_UV_Process::test_process_streams_redirect"
62 "--deselect=tests/test_process.py::Test_AIO_Process::test_process_streams_redirect"
63 ] ++ lib.optionals (stdenv.isDarwin) [
64 # Segmentation fault
65 "--deselect=tests/test_fs_event.py::Test_UV_FS_EVENT_RENAME::test_fs_event_rename"
66 # Broken: https://github.com/NixOS/nixpkgs/issues/160904
67 "--deselect=tests/test_context.py::Test_UV_Context::test_create_ssl_server_manual_connection_lost"
68 ];
69
70 disabledTestPaths = [
71 # ignore code linting tests
72 "tests/test_sourcecode.py"
73 ];
74
75 preCheck = ''
76 # force using installed/compiled uvloop
77 rm -rf uvloop
78 '' + lib.optionalString stdenv.isDarwin ''
79 # Work around "OSError: AF_UNIX path too long"
80 # https://github.com/MagicStack/uvloop/issues/463
81 export TMPDIR="/tmp"
82 '';
83
84 pythonImportsCheck = [
85 "uvloop"
86 "uvloop.loop"
87 ];
88
89 # Some of the tests use localhost networking.
90 __darwinAllowLocalNetworking = true;
91
92 meta = with lib; {
93 changelog = "https://github.com/MagicStack/uvloop/releases/tag/v${version}";
94 description = "Fast implementation of asyncio event loop on top of libuv";
95 homepage = "https://github.com/MagicStack/uvloop";
96 license = licenses.mit;
97 maintainers = with maintainers; [ ];
98 };
99}