1{ lib
2, stdenv
3, buildPythonPackage
4, pythonOlder
5, fetchPypi
6, libuv
7, CoreServices
8, ApplicationServices
9# Check Inputs
10, aiohttp
11, psutil
12, pyopenssl
13, pytestCheckHook
14}:
15
16buildPythonPackage rec {
17 pname = "uvloop";
18 version = "0.15.2";
19 disabled = pythonOlder "3.7";
20
21 src = fetchPypi {
22 inherit pname version;
23 sha256 = "2bb0624a8a70834e54dde8feed62ed63b50bad7a1265c40d6403a2ac447bce01";
24 };
25
26 buildInputs = [
27 libuv
28 ] ++ lib.optionals stdenv.isDarwin [
29 CoreServices
30 ApplicationServices
31 ];
32
33 dontUseSetuptoolsCheck = true;
34 checkInputs = [
35 aiohttp
36 pytestCheckHook
37 pyopenssl
38 psutil
39 ];
40
41 pytestFlagsArray = [
42 # from pytest.ini, these are NECESSARY to prevent failures
43 "--capture=no"
44 "--assert=plain"
45 "--strict"
46 "--tb=native"
47 ] ++ lib.optionals (stdenv.isAarch64) [
48 # test gets stuck in epoll_pwait on hydras aarch64 builders
49 # https://github.com/MagicStack/uvloop/issues/412
50 "--deselect" "tests/test_tcp.py::Test_AIO_TCPSSL::test_remote_shutdown_receives_trailing_data"
51 ];
52
53 disabledTestPaths = [
54 # ignore code linting tests
55 "tests/test_sourcecode.py"
56 ];
57
58 # force using installed/compiled uvloop vs source by moving tests to temp dir
59 preCheck = ''
60 export TEST_DIR=$(mktemp -d)
61 cp -r tests $TEST_DIR
62 pushd $TEST_DIR
63 '';
64
65 postCheck = ''
66 popd
67 '';
68
69 pythonImportsCheck = [
70 "uvloop"
71 "uvloop.loop"
72 ];
73
74 # Some of the tests use localhost networking.
75 __darwinAllowLocalNetworking = true;
76
77 meta = with lib; {
78 description = "Fast implementation of asyncio event loop on top of libuv";
79 homepage = "https://github.com/MagicStack/uvloop";
80 license = licenses.mit;
81 maintainers = with maintainers; [ costrouc ];
82 };
83}