nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.16.0";
19 disabled = pythonOlder "3.7";
20
21 src = fetchPypi {
22 inherit pname version;
23 sha256 = "f74bc20c7b67d1c27c72601c78cf95be99d5c2cdd4514502b4f3eb0933ff1228";
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 LIBUV_CONFIGURE_HOST = stdenv.hostPlatform.config;
42
43 pytestFlagsArray = [
44 # from pytest.ini, these are NECESSARY to prevent failures
45 "--capture=no"
46 "--assert=plain"
47 "--strict"
48 "--tb=native"
49 ] ++ lib.optionals (stdenv.isAarch64) [
50 # test gets stuck in epoll_pwait on hydras aarch64 builders
51 # https://github.com/MagicStack/uvloop/issues/412
52 "--deselect" "tests/test_tcp.py::Test_AIO_TCPSSL::test_remote_shutdown_receives_trailing_data"
53 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
54 # Flaky test: https://github.com/MagicStack/uvloop/issues/412
55 "--deselect" "tests/test_tcp.py::Test_UV_TCPSSL::test_shutdown_timeout_handler_not_set"
56 # Broken: https://github.com/NixOS/nixpkgs/issues/160904
57 "--deselect" "tests/test_context.py::Test_UV_Context::test_create_ssl_server_manual_connection_lost"
58 ];
59
60 disabledTestPaths = [
61 # ignore code linting tests
62 "tests/test_sourcecode.py"
63 ];
64
65 preCheck = lib.optionalString stdenv.isDarwin ''
66 # Work around "OSError: AF_UNIX path too long"
67 # https://github.com/MagicStack/uvloop/issues/463
68 export TMPDIR="/tmp"
69 '' + ''
70 # force using installed/compiled uvloop vs source by moving tests to temp dir
71 export TEST_DIR=$(mktemp -d)
72 cp -r tests $TEST_DIR
73 pushd $TEST_DIR
74 '';
75
76 postCheck = ''
77 popd
78 '';
79
80 pythonImportsCheck = [
81 "uvloop"
82 "uvloop.loop"
83 ];
84
85 # Some of the tests use localhost networking.
86 __darwinAllowLocalNetworking = true;
87
88 meta = with lib; {
89 description = "Fast implementation of asyncio event loop on top of libuv";
90 homepage = "https://github.com/MagicStack/uvloop";
91 license = licenses.mit;
92 maintainers = with maintainers; [ costrouc ];
93 };
94}