Open blshkv opened 10 months ago
I'm trying to use Cython 3.0.6 in the Fedora's uvloop package updated to 0.19.0.
I'm getting:
tests/test_base.py::TestBaseUV::test_check_thread Unexpected calls to loop.call_exception_handler():
[{'exception': TypeError('wrap() takes exactly 2 positional arguments (3 given)'),
'handle': <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap created at /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py:254>,
'message': 'Exception in callback <bound method '
'__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap '
'of <uvloop.Loop running=True closed=False debug=True>>',
'source_traceback': [<FrameSummary file /usr/lib64/python3.12/threading.py, line 1030 in _bootstrap>,
<FrameSummary file /usr/lib64/python3.12/threading.py, line 1073 in _bootstrap_inner>,
<FrameSummary file /usr/lib64/python3.12/threading.py, line 1010 in run>,
<FrameSummary file /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py, line 283 in check_in_thread>,
<FrameSummary file /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py, line 254 in check_thread>]},
{'exception': TypeError('wrap() takes exactly 2 positional arguments (3 given)'),
'handle': <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap>,
'message': 'Exception in callback <bound method '
'__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap '
'of <uvloop.Loop running=True closed=False debug=False>>'},
{'exception': TypeError('wrap() takes exactly 2 positional arguments (3 given)'),
'handle': <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap created at /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py:254>,
'message': 'Exception in callback <bound method '
'__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap '
'of <uvloop.Loop running=True closed=False debug=True>>',
'source_traceback': [<FrameSummary file /usr/lib64/python3.12/threading.py, line 1030 in _bootstrap>,
<FrameSummary file /usr/lib64/python3.12/threading.py, line 1073 in _bootstrap_inner>,
<FrameSummary file /usr/lib64/python3.12/threading.py, line 1010 in run>,
<FrameSummary file /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py, line 278 in check_in_thread>,
<FrameSummary file /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py, line 254 in check_thread>]},
{'exception': TypeError('wrap() takes exactly 2 positional arguments (3 given)'),
'handle': <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap>,
'message': 'Exception in callback <bound method '
'__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap '
'of <uvloop.Loop running=True closed=False debug=False>>'}]
FAILED
...
tests/test_process.py::Test_UV_Process::test_process_double_close <frozen importlib._bootstrap>:488: UserWarning: enum class uv_fs_event not importable from uvloop.includes.uv. You are probably using a cpdef enum declared in a .pxd file that does not have a .py or .pyx file.
PASSED
And:
=================================== FAILURES ===================================
_________________________ TestBaseUV.test_check_thread _________________________
Traceback (most recent call last):
File "/usr/lib64/python3.12/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib64/python3.12/unittest/case.py", line 639, in run
self._callTearDown()
File "/usr/lib64/python3.12/unittest/case.py", line 594, in _callTearDown
self.tearDown()
File "/builddir/build/BUILDROOT/python-uvloop-0.19.0-1.fc40.x86_64/usr/lib64/python3.12/site-packages/uvloop/_testbase.py", line 106, in tearDown
self.fail('unexpected calls to loop.call_exception_handler()')
File "/usr/lib64/python3.12/unittest/case.py", line 717, in fail
raise self.failureException(msg)
AssertionError: unexpected calls to loop.call_exception_handler()
------------------------------ Captured log call -------------------------------
ERROR asyncio:_testbase.py:89 Exception in callback <bound method __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap of <uvloop.Loop running=True closed=False debug=True>>
handle: <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap created at /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py:254>
source_traceback: Object created at (most recent call last):
File "/usr/lib64/python3.12/threading.py", line 1030, in _bootstrap
self._bootstrap_inner()
File "/usr/lib64/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py", line 283, in check_in_thread
check_thread(loop, debug)
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py", line 254, in check_thread
loop.set_debug(debug)
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 63, in uvloop.loop.Handle._run
File "<stringsource>", line 67, in cfunc.to_py.__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.wrap
TypeError: wrap() takes exactly 2 positional arguments (3 given)
ERROR asyncio:_testbase.py:89 Exception in callback <bound method __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap of <uvloop.Loop running=True closed=False debug=False>>
handle: <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 63, in uvloop.loop.Handle._run
File "<stringsource>", line 67, in cfunc.to_py.__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.wrap
TypeError: wrap() takes exactly 2 positional arguments (3 given)
ERROR asyncio:_testbase.py:89 Exception in callback <bound method __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap of <uvloop.Loop running=True closed=False debug=True>>
handle: <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap created at /builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py:254>
source_traceback: Object created at (most recent call last):
File "/usr/lib64/python3.12/threading.py", line 1030, in _bootstrap
self._bootstrap_inner()
File "/usr/lib64/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py", line 278, in check_in_thread
check_thread(loop, debug)
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_base.py", line 254, in check_thread
loop.set_debug(debug)
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 63, in uvloop.loop.Handle._run
File "<stringsource>", line 67, in cfunc.to_py.__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.wrap
TypeError: wrap() takes exactly 2 positional arguments (3 given)
ERROR asyncio:_testbase.py:89 Exception in callback <bound method __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap of <uvloop.Loop running=True closed=False debug=False>>
handle: <Handle __Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.<locals>.wrap>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 63, in uvloop.loop.Handle._run
File "<stringsource>", line 67, in cfunc.to_py.__Pyx_CFunc_object__lParenLoop__comma_bint__rParen_to_py_4self_7enabled.wrap
TypeError: wrap() takes exactly 2 positional arguments (3 given)
_____ Test_UV_Process_Delayed.test_process_delayed_stdio__paused__no_stdin _____
Traceback (most recent call last):
File "/usr/lib64/python3.12/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib64/python3.12/unittest/case.py", line 636, in run
self._callTestMethod(testMethod)
File "/usr/lib64/python3.12/unittest/case.py", line 589, in _callTestMethod
if method() is not None:
^^^^^^^^
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_process.py", line 929, in test_process_delayed_stdio__paused__no_stdin
transport, proto = self.loop.run_until_complete(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_process.py", line 904, in run_sub
return await self.loop.subprocess_shell(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 2808, in subprocess_shell
File "uvloop/loop.pyx", line 2734, in uvloop.loop.Loop._Loop__subprocess_run
TypeError: _Loop__subprocess_run() got an unexpected keyword argument '__uvloop_sleep_after_fork'
____ Test_UV_Process_Delayed.test_process_delayed_stdio__paused__stdin_pipe ____
Traceback (most recent call last):
File "/usr/lib64/python3.12/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib64/python3.12/unittest/case.py", line 636, in run
self._callTestMethod(testMethod)
File "/usr/lib64/python3.12/unittest/case.py", line 589, in _callTestMethod
if method() is not None:
^^^^^^^^
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_process.py", line 910, in test_process_delayed_stdio__paused__stdin_pipe
transport, proto = self.loop.run_until_complete(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/builddir/build/BUILD/uvloop-0.19.0/_empty/tests/test_process.py", line 904, in run_sub
return await self.loop.subprocess_shell(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 2808, in subprocess_shell
File "uvloop/loop.pyx", line 2734, in uvloop.loop.Loop._Loop__subprocess_run
TypeError: _Loop__subprocess_run() got an unexpected keyword argument '__uvloop_sleep_after_fork'
When running the tests.
ok, my bad about an artificial requirement. You must follow https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html and fix the code
I kinda suspect https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#binding-functions but the binding=False
directive does not help (or I am not passing it correctly).
Notice that it doesn't work with older Cython (<3).
The following worked for me in ALT Linux Sisyphus (build log): https://git.altlinux.org/tasks/336746/build/100/x86_64/log.
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
Thank you, @Ancieg! I can confirm this makes the tests pass with Cython 3.0.6.
Above patch is not enough on use pep517 based build procedure
+ /usr/bin/python3 -sBm build -w --no-isolation
* Getting build dependencies for wheel...
ERROR Missing dependencies:
Cython<0.30.0,>=0.29.36
On top of that patch needs to be added:
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@
from setuptools.command.sdist import sdist
-CYTHON_DEPENDENCY = 'Cython(>=0.29.36,<0.30.0)'
+CYTHON_DEPENDENCY = 'Cython(>=0.29.36)'
MACHINE = platform.machine()
_ROOT = pathlib.Path(__file__).parent
LIBUV_DIR = str(_ROOT / 'vendor' / 'libuv')
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -43,7 +43,7 @@
'pycodestyle~=2.9.0',
'pyOpenSSL~=23.0.0',
'mypy>=0.800',
- 'Cython(>=0.29.36,<0.30.0)',
+ 'Cython(>=0.29.36)',
]
docs = [
'Sphinx~=4.1.2',
@@ -55,7 +55,7 @@
requires = [
"setuptools>=60",
"wheel",
- "Cython(>=0.29.36,<0.30.0)",
+ "Cython(>=0.29.36)",
]
build-backend = "setuptools.build_meta"
(if proposed patch still works with cython
<3).
Just tested proposed patch + my chunks and build
passes .. however
If someone may help on resolve pytest issue please continue on https://github.com/MagicStack/uvloop/issues/429
Think this can now be closed
This is seem an artificial requirement: https://github.com/MagicStack/uvloop/blob/master/setup.py#L24
Could you please test it with newer version and update? Thanks