2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, pyopenssl
|
|
|
|
, libuv
|
|
|
|
, psutil
|
|
|
|
, isPy27
|
2020-08-20 17:08:02 +00:00
|
|
|
, pythonAtLeast
|
2020-04-24 23:36:52 +00:00
|
|
|
, CoreServices
|
|
|
|
, ApplicationServices
|
|
|
|
# Check Inputs
|
|
|
|
, pytestCheckHook
|
|
|
|
# , pytest-asyncio
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "uvloop";
|
|
|
|
version = "0.14.0";
|
|
|
|
disabled = isPy27;
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
|
|
|
sha256 = "07j678z9gf41j98w72ysrnb5sa41pl5yxd7ib17lcwfxqz0cjfhj";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = lib.optional stdenv.isDarwin ./darwin_sandbox.patch;
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libuv
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [ CoreServices ApplicationServices ];
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"uvloop"
|
|
|
|
"uvloop.loop"
|
|
|
|
];
|
|
|
|
|
|
|
|
dontUseSetuptoolsCheck = true;
|
|
|
|
checkInputs = [ pytestCheckHook pyopenssl psutil ];
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
# from pytest.ini, these are NECESSARY to prevent failures
|
|
|
|
"--capture=no"
|
|
|
|
"--assert=plain"
|
|
|
|
"--tb=native"
|
|
|
|
# ignore code linting tests
|
|
|
|
"--ignore=tests/test_sourcecode.py"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
"test_sock_cancel_add_reader_race" # asyncio version of test is supposed to be skipped but skip doesn't happen. uvloop version runs fine
|
2020-08-20 17:08:02 +00:00
|
|
|
] ++ lib.optionals (pythonAtLeast "3.8") [ "test_write_to_closed_transport" ]; # https://github.com/MagicStack/uvloop/issues/355
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# force using installed/compiled uvloop vs source by moving tests to temp dir
|
|
|
|
preCheck = ''
|
|
|
|
export TEST_DIR=$(mktemp -d)
|
|
|
|
cp -r tests $TEST_DIR
|
|
|
|
pushd $TEST_DIR
|
2020-06-15 15:56:04 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# Some tests fail on Darwin
|
|
|
|
rm tests/test_[stu]*.py
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
postCheck = ''
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Some of the tests use localhost networking.
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Fast implementation of asyncio event loop on top of libuv";
|
|
|
|
homepage = "https://github.com/MagicStack/uvloop";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ costrouc ];
|
2020-12-07 07:45:13 +00:00
|
|
|
broken = pythonAtLeast "3.9"; # see: https://github.com/MagicStack/uvloop/issues/365
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|