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