Skip to content

Commit

Permalink
uvloop: fork, add cython 3 support. See MagicStack/uvloop#586
Browse files Browse the repository at this point in the history
  • Loading branch information
blshkv committed Dec 21, 2023
1 parent 3b24e2c commit 599f8d1
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-python/uvloop/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST uvloop-0.19.0.tar.gz 2318492 BLAKE2B 1c46a8bf3e204c261e3a5e60c3583b75b8b9b20086443725c42842f96ea3f6804242470aa9569f8cc74a6e3bd38b5aaa70f9a9d92b5df3e73911acc169185570 SHA512 b6ca7ba7baf61dc930bb92e35013e5abaf7a227a5e99c88ec4b58fa87a40692151d9891b81d9e514a8481df62bb9721baa789ec234dcbbb34f69e0bee489c57c
44 changes: 44 additions & 0 deletions dev-python/uvloop/files/586.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 8e5da4e53daf03089ad83e007d378a4888fca729 Mon Sep 17 00:00:00 2001
From: Anton Zhukharev <ancieg@altlinux.org>
Date: Tue, 19 Dec 2023 12:41:58 +0300
Subject: [PATCH] fix compatibility with cython>3

---
uvloop/loop.pyx | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx
index b0ffa8b..fb1d5e6 100644
--- a/uvloop/loop.pyx
+++ b/uvloop/loop.pyx
@@ -1397,7 +1397,7 @@ cdef class Loop:
self._debug = bool(enabled)
if self.is_running():
self.call_soon_threadsafe(
- self._set_coroutine_debug, self, self._debug)
+ self._set_coroutine_debug, self._debug)

def is_running(self):
"""Return whether the event loop is currently running."""
@@ -2749,8 +2749,7 @@ cdef class Loop:
start_new_session=False,
executable=None,
pass_fds=(),
- # For tests only! Do not use in your code. Ever.
- __uvloop_sleep_after_fork=False):
+ **kwargs):

# TODO: Implement close_fds (might not be very important in
# Python 3.5, since all FDs aren't inheritable by default.)
@@ -2770,7 +2769,8 @@ cdef class Loop:
if executable is not None:
args[0] = executable

- if __uvloop_sleep_after_fork:
+ # For tests only! Do not use in your code. Ever.
+ if kwargs.get('__uvloop_sleep_after_fork'):
debug_flags |= __PROCESS_DEBUG_SLEEP_AFTER_FORK

waiter = self._new_future()
--
2.42.1
16 changes: 16 additions & 0 deletions dev-python/uvloop/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>python@gentoo.org</email>
</maintainer>
<longdescription>
uvloop is a fast, drop-in replacement of the built-in asyncio
event loop. uvloop is implemented in Cython and uses libuv under
the hood.
</longdescription>
<upstream>
<remote-id type="pypi">uvloop</remote-id>
<remote-id type="github">magicstack/uvloop</remote-id>
</upstream>
</pkgmetadata>
95 changes: 95 additions & 0 deletions dev-python/uvloop/uvloop-0.19.0-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{10..12} )

inherit distutils-r1 pypi

DESCRIPTION="Ultra-fast implementation of asyncio event loop on top of libuv"
HOMEPAGE="
https://github.com/magicstack/uvloop/
https://pypi.org/project/uvloop/
"

KEYWORDS="amd64 arm arm64 ppc ppc64 -riscv sparc x86"
LICENSE="MIT"
SLOT="0"
IUSE="examples"

DEPEND="
>=dev-libs/libuv-1.11.0:=
"
RDEPEND="
${DEPEND}
"
BDEPEND="
>dev-python/cython-3[${PYTHON_USEDEP}]
test? (
dev-python/aiohttp[${PYTHON_USEDEP}]
>=dev-python/pyopenssl-22.0.0[${PYTHON_USEDEP}]
dev-python/psutil[${PYTHON_USEDEP}]
)
"

PATCHES=(
"${FILESDIR}/586.patch"
)

distutils_enable_tests pytest

python_prepare_all() {
rm -r vendor || die
cat <<-EOF >> setup.cfg || die
[build_ext]
use_system_libuv=True
cython_always=True
EOF

# flake8 only
#rm tests/test_sourcecode.py || die
# force cythonization
rm uvloop/loop.c || die
# hangs
#sed -i -e 's:test_remote_shutdown_receives_trailing_data:_&:' \
# tests/test_tcp.py || die

distutils-r1_python_prepare_all
}

python_test() {
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
local EPYTEST_IGNORE=(
# linting
tests/test_sourcecode.py
)
local EPYTEST_DESELECT=(
# TODO: expects some... cython_helper?
tests/test_libuv_api.py::Test_UV_libuv::test_libuv_get_loop_t_ptr
# unhappy about sandbox injecting its envvars
tests/test_process.py::Test_UV_Process::test_process_env_2
tests/test_process.py::Test_AIO_Process::test_process_env_2
# hangs
tests/test_tcp.py::Test_AIO_TCPSSL::test_remote_shutdown_receives_trailing_data
# crashes on assertion
# https://github.com/MagicStack/uvloop/issues/574
tests/test_cython.py::TestCythonIntegration::test_cython_coro_is_coroutine
)

rm -rf uvloop || die
epytest -s
}

src_prepare() {
#https://github.com/MagicStack/uvloop/issues/586
sed -i -e "s|Cython(>=0.29.36,<0.30.0)|Cython(>0.30.0)|" setup.py || die
eapply_user
}

python_install_all() {
use examples && dodoc -r examples
distutils-r1_python_install_all
}

0 comments on commit 599f8d1

Please sign in to comment.