commit 64699d31db21942434950b532178216f10f9a997 Author: tigro Date: Sat Jan 4 22:52:58 2025 +0300 import python-uvloop-0.19.0-5.el10 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3d6e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/uvloop-0.19.0.tar.gz diff --git a/.python-uvloop.metadata b/.python-uvloop.metadata new file mode 100644 index 0000000..7c04d05 --- /dev/null +++ b/.python-uvloop.metadata @@ -0,0 +1 @@ +89c40917b2296c19ba53d0d572472dca144be291 SOURCES/uvloop-0.19.0.tar.gz diff --git a/SOURCES/587.patch b/SOURCES/587.patch new file mode 100644 index 0000000..9f47db9 --- /dev/null +++ b/SOURCES/587.patch @@ -0,0 +1,723 @@ +From 83ae19d273bed781e653cdcfe55b9127ef2fbb58 Mon Sep 17 00:00:00 2001 +From: Alan Brooks <12380017+alan-brooks@users.noreply.github.com> +Date: Thu, 28 Dec 2023 12:18:15 +0000 +Subject: [PATCH 1/4] Updates for Cython3 Remove SSL depreciation warnings + buillt on debian 12.6 python-3.22 Cython-3.0.7 libuv-1.46.0 + +--- + Makefile | 2 +- + setup.py | 6 ++++-- + tests/test_process.py | 4 ++-- + tests/test_tcp.py | 19 ++++++++++++------- + uvloop/_testbase.py | 4 +++- + uvloop/cbhandles.pyx | 4 ++-- + uvloop/dns.pyx | 4 ++-- + uvloop/handles/basetransport.pxd | 4 ++-- + uvloop/handles/basetransport.pyx | 4 ++-- + uvloop/handles/handle.pyx | 2 +- + uvloop/handles/pipe.pyx | 2 +- + uvloop/handles/poll.pxd | 2 +- + uvloop/handles/poll.pyx | 2 +- + uvloop/handles/stream.pyx | 16 ++++++++++------ + uvloop/handles/udp.pyx | 4 ++-- + uvloop/includes/consts.pxi | 25 ------------------------- + uvloop/includes/fork_handler.h | 6 +++++- + uvloop/includes/system.h | 16 ++++++++++++++++ + uvloop/includes/system.pxd | 12 ++++-------- + uvloop/includes/uv.pxd | 6 +++--- + uvloop/loop.pxd | 28 ++++++++++++++++++++++++---- + uvloop/loop.pyx | 10 +++++----- + uvloop/sslproto.pxd | 4 ++-- + uvloop/sslproto.pyx | 4 ++-- + 24 files changed, 107 insertions(+), 83 deletions(-) + delete mode 100644 uvloop/includes/consts.pxi + create mode 100755 uvloop/includes/system.h + +diff --git a/Makefile b/Makefile +index 4375e5d2..6a0475a9 100644 +--- a/Makefile ++++ b/Makefile +@@ -9,7 +9,7 @@ _default: compile + + + clean: +- rm -fr dist/ doc/_build/ *.egg-info uvloop/loop.*.pyd ++ rm -fr dist/ doc/_build/ *.egg-info uvloop/loop.*.pyd uvloop/loop_d.*.pyd + rm -fr uvloop/*.c uvloop/*.html uvloop/*.so + rm -fr uvloop/handles/*.html uvloop/includes/*.html + find . -name '__pycache__' | xargs rm -rf +diff --git a/setup.py b/setup.py +index ba15af50..8fdf0e56 100644 +--- 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() + MODULES_CFLAGS = [os.getenv('UVLOOP_OPT_CFLAGS', '-O2')] + _ROOT = pathlib.Path(__file__).parent +@@ -144,7 +144,9 @@ def finalize_options(self): + self.distribution.ext_modules[:] = cythonize( + self.distribution.ext_modules, + compiler_directives=directives, +- annotate=self.cython_annotate) ++ annotate=self.cython_annotate, ++ compile_time_env=dict(DEFAULT_FREELIST_SIZE=250, SSL_READ_MAX_SIZE=256 * 1024), ++ emit_linenums=True) + + super().finalize_options() + +diff --git a/tests/test_process.py b/tests/test_process.py +index bfcbba17..95e1c9e7 100644 +--- a/tests/test_process.py ++++ b/tests/test_process.py +@@ -912,7 +912,7 @@ def test_process_delayed_stdio__paused__stdin_pipe(self): + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, +- __uvloop_sleep_after_fork=True)) ++ uvloop_sleep_after_fork=True)) + self.assertIsNot(transport, None) + self.assertEqual(transport.get_returncode(), 0) + self.assertEqual( +@@ -931,7 +931,7 @@ def test_process_delayed_stdio__paused__no_stdin(self): + stdin=None, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, +- __uvloop_sleep_after_fork=True)) ++ uvloop_sleep_after_fork=True)) + self.assertIsNot(transport, None) + self.assertEqual(transport.get_returncode(), 0) + self.assertEqual( +diff --git a/tests/test_tcp.py b/tests/test_tcp.py +index 812e62b8..213e2d9f 100644 +--- a/tests/test_tcp.py ++++ b/tests/test_tcp.py +@@ -1630,17 +1630,22 @@ async def client(addr): + self.fail("unexpected call to connection_made()") + + def test_ssl_connect_accepted_socket(self): +- if hasattr(ssl, 'PROTOCOL_TLS'): +- proto = ssl.PROTOCOL_TLS ++ if hasattr(ssl, 'PROTOCOL_TLS_SERVER'): ++ server_proto = ssl.PROTOCOL_TLS_SERVER ++ client_proto = ssl.PROTOCOL_TLS_CLIENT + else: +- proto = ssl.PROTOCOL_SSLv23 +- server_context = ssl.SSLContext(proto) ++ if hasattr(ssl, 'PROTOCOL_TLS'): ++ client_proto = server_proto = ssl.PROTOCOL_TLS ++ else: ++ client_proto = server_proto = ssl.PROTOCOL_SSLv23 ++ ++ server_context = ssl.SSLContext(server_proto) + server_context.load_cert_chain(self.ONLYCERT, self.ONLYKEY) + if hasattr(server_context, 'check_hostname'): + server_context.check_hostname = False + server_context.verify_mode = ssl.CERT_NONE + +- client_context = ssl.SSLContext(proto) ++ client_context = ssl.SSLContext(client_proto) + if hasattr(server_context, 'check_hostname'): + client_context.check_hostname = False + client_context.verify_mode = ssl.CERT_NONE +@@ -2233,7 +2238,7 @@ def test_renegotiation(self): + sslctx.use_privatekey_file(self.ONLYKEY) + sslctx.use_certificate_chain_file(self.ONLYCERT) + client_sslctx = self._create_client_ssl_context() +- if hasattr(ssl, 'OP_NO_TLSv1_3'): ++ if sys.version_info < (3, 8) and hasattr(ssl, 'OP_NO_TLSv1_3'): + client_sslctx.options |= ssl.OP_NO_TLSv1_3 + + def server(sock): +@@ -2592,7 +2597,7 @@ def test_flush_before_shutdown(self): + sslctx_openssl.use_privatekey_file(self.ONLYKEY) + sslctx_openssl.use_certificate_chain_file(self.ONLYCERT) + client_sslctx = self._create_client_ssl_context() +- if hasattr(ssl, 'OP_NO_TLSv1_3'): ++ if sys.version_info < (3, 8) and hasattr(ssl, 'OP_NO_TLSv1_3'): + client_sslctx.options |= ssl.OP_NO_TLSv1_3 + + future = None +diff --git a/uvloop/_testbase.py b/uvloop/_testbase.py +index c4a7595b..e620e158 100644 +--- a/uvloop/_testbase.py ++++ b/uvloop/_testbase.py +@@ -269,7 +269,9 @@ def find_free_port(start_from=50000): + class SSLTestCase: + + def _create_server_ssl_context(self, certfile, keyfile=None): +- if hasattr(ssl, 'PROTOCOL_TLS'): ++ if hasattr(ssl, 'PROTOCOL_TLS_SERVER'): ++ sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) ++ elif hasattr(ssl, 'PROTOCOL_TLS'): + sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLS) + else: + sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) +diff --git a/uvloop/cbhandles.pyx b/uvloop/cbhandles.pyx +index 2914b42e..8bcc5aa6 100644 +--- a/uvloop/cbhandles.pyx ++++ b/uvloop/cbhandles.pyx +@@ -76,8 +76,8 @@ cdef class Handle: + self.arg1, self.arg2, self.arg3, self.arg4) + + else: +- raise RuntimeError('invalid Handle.cb_type: {}'.format( +- cb_type)) ++ raise RuntimeError('invalid Handle.cb_type: {} {!r}/{!r}'.format( ++ cb_type, self.args1, self.args2)) + + except (KeyboardInterrupt, SystemExit): + raise +diff --git a/uvloop/dns.pyx b/uvloop/dns.pyx +index 7aad6319..09b92828 100644 +--- a/uvloop/dns.pyx ++++ b/uvloop/dns.pyx +@@ -298,7 +298,7 @@ cdef class AddrInfo: + uv.uv_freeaddrinfo(self.data) # returns void + self.data = NULL + +- cdef void set_data(self, system.addrinfo *data): ++ cdef void set_data(self, system.addrinfo *data) noexcept: + self.data = data + + cdef unpack(self): +@@ -326,7 +326,7 @@ cdef class AddrInfo: + return result + + @staticmethod +- cdef int isinstance(object other): ++ cdef int isinstance(object other) noexcept: + return type(other) is AddrInfo + + +diff --git a/uvloop/handles/basetransport.pxd b/uvloop/handles/basetransport.pxd +index ba356a78..8112622c 100644 +--- a/uvloop/handles/basetransport.pxd ++++ b/uvloop/handles/basetransport.pxd +@@ -47,8 +47,8 @@ cdef class UVBaseTransport(UVSocketHandle): + # === overloads === + + cdef _new_socket(self) +- cdef size_t _get_write_buffer_size(self) ++ cdef size_t _get_write_buffer_size(self) noexcept + +- cdef bint _is_reading(self) ++ cdef bint _is_reading(self) noexcept + cdef _start_reading(self) + cdef _stop_reading(self) +diff --git a/uvloop/handles/basetransport.pyx b/uvloop/handles/basetransport.pyx +index 28b30794..a8592f2d 100644 +--- a/uvloop/handles/basetransport.pyx ++++ b/uvloop/handles/basetransport.pyx +@@ -18,7 +18,7 @@ cdef class UVBaseTransport(UVSocketHandle): + + self._closing = 0 + +- cdef size_t _get_write_buffer_size(self): ++ cdef size_t _get_write_buffer_size(self) noexcept: + return 0 + + cdef inline _schedule_call_connection_made(self): +@@ -211,7 +211,7 @@ cdef class UVBaseTransport(UVSocketHandle): + self._extra_info = {} + self._extra_info[name] = obj + +- cdef bint _is_reading(self): ++ cdef bint _is_reading(self) noexcept: + raise NotImplementedError + + cdef _start_reading(self): +diff --git a/uvloop/handles/handle.pyx b/uvloop/handles/handle.pyx +index 6efe3755..2c96458b 100644 +--- a/uvloop/handles/handle.pyx ++++ b/uvloop/handles/handle.pyx +@@ -363,7 +363,7 @@ cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) noexcept with gil: + Py_DECREF(h) # Was INCREFed in UVHandle._close + + +-cdef void __close_all_handles(Loop loop): ++cdef void __close_all_handles(Loop loop) noexcept: + uv.uv_walk(loop.uvloop, + __uv_walk_close_all_handles_cb, + loop) # void +diff --git a/uvloop/handles/pipe.pyx b/uvloop/handles/pipe.pyx +index 195576c7..d30a7366 100644 +--- a/uvloop/handles/pipe.pyx ++++ b/uvloop/handles/pipe.pyx +@@ -25,7 +25,7 @@ cdef __pipe_init_uv_handle(UVStream handle, Loop loop): + cdef __pipe_open(UVStream handle, int fd): + cdef int err + err = uv.uv_pipe_open(handle._handle, +- fd) ++ fd) + if err < 0: + exc = convert_error(err) + raise exc +diff --git a/uvloop/handles/poll.pxd b/uvloop/handles/poll.pxd +index d07030b5..c2205402 100644 +--- a/uvloop/handles/poll.pxd ++++ b/uvloop/handles/poll.pxd +@@ -10,7 +10,7 @@ cdef class UVPoll(UVHandle): + cdef inline _poll_start(self, int flags) + cdef inline _poll_stop(self) + +- cdef int is_active(self) ++ cdef int is_active(self) noexcept + + cdef is_reading(self) + cdef is_writing(self) +diff --git a/uvloop/handles/poll.pyx b/uvloop/handles/poll.pyx +index fca5981e..c905e9b0 100644 +--- a/uvloop/handles/poll.pyx ++++ b/uvloop/handles/poll.pyx +@@ -29,7 +29,7 @@ cdef class UVPoll(UVHandle): + handle._init(loop, fd) + return handle + +- cdef int is_active(self): ++ cdef int is_active(self) noexcept: + return (self.reading_handle is not None or + self.writing_handle is not None) + +diff --git a/uvloop/handles/stream.pyx b/uvloop/handles/stream.pyx +index d4e02e3e..09df8878 100644 +--- a/uvloop/handles/stream.pyx ++++ b/uvloop/handles/stream.pyx +@@ -1,4 +1,8 @@ +-DEF __PREALLOCED_BUFS = 4 ++cdef extern from *: ++ ''' ++ enum {__PREALLOCED_BUFS = 4}; ++ ''' ++ const bint __PREALLOCED_BUFS + + + @cython.no_gc_clear +@@ -279,7 +283,7 @@ cdef class UVStream(UVBaseTransport): + cdef inline _close_on_read_error(self): + self.__read_error_close = 1 + +- cdef bint _is_reading(self): ++ cdef bint _is_reading(self) noexcept: + return self.__reading + + cdef _start_reading(self): +@@ -578,7 +582,7 @@ cdef class UVStream(UVBaseTransport): + + self._maybe_resume_protocol() + +- cdef size_t _get_write_buffer_size(self): ++ cdef size_t _get_write_buffer_size(self) noexcept: + if self._handle is NULL: + return 0 + return ((self._handle).write_queue_size + +@@ -755,7 +759,7 @@ cdef inline bint __uv_stream_on_read_common( + UVStream sc, + Loop loop, + ssize_t nread, +-): ++) noexcept: + if sc._closed: + # The stream was closed, there is no reason to + # do any work now. +@@ -818,7 +822,7 @@ cdef inline void __uv_stream_on_read_impl( + uv.uv_stream_t* stream, + ssize_t nread, + const uv.uv_buf_t* buf, +-): ++) noexcept: + cdef: + UVStream sc = stream.data + Loop loop = sc._loop +@@ -849,7 +853,7 @@ cdef inline void __uv_stream_on_read_impl( + cdef inline void __uv_stream_on_write_impl( + uv.uv_write_t* req, + int status, +-): ++) noexcept: + cdef: + _StreamWriteContext ctx = <_StreamWriteContext> req.data + UVStream stream = ctx.stream +diff --git a/uvloop/handles/udp.pyx b/uvloop/handles/udp.pyx +index bbe60d56..fdd1d8b2 100644 +--- a/uvloop/handles/udp.pyx ++++ b/uvloop/handles/udp.pyx +@@ -127,12 +127,12 @@ cdef class UDPTransport(UVBaseTransport): + exc = convert_error(err) + raise exc + +- cdef size_t _get_write_buffer_size(self): ++ cdef size_t _get_write_buffer_size(self) noexcept: + if self._handle is NULL: + return 0 + return (self._handle).send_queue_size + +- cdef bint _is_reading(self): ++ cdef bint _is_reading(self) noexcept: + return self.__receiving + + cdef _start_reading(self): +diff --git a/uvloop/includes/consts.pxi b/uvloop/includes/consts.pxi +deleted file mode 100644 +index f765053d..00000000 +--- a/uvloop/includes/consts.pxi ++++ /dev/null +@@ -1,25 +0,0 @@ +-DEF UV_STREAM_RECV_BUF_SIZE = 256000 # 250kb +- +-DEF FLOW_CONTROL_HIGH_WATER = 64 # KiB +-DEF FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB +-DEF FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB +- +-DEF DEFAULT_FREELIST_SIZE = 250 +-DEF DNS_PYADDR_TO_SOCKADDR_CACHE_SIZE = 2048 +- +-DEF DEBUG_STACK_DEPTH = 10 +- +- +-DEF __PROCESS_DEBUG_SLEEP_AFTER_FORK = 1 +- +- +-DEF LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 +- +- +-# Number of seconds to wait for SSL handshake to complete +-# The default timeout matches that of Nginx. +-DEF SSL_HANDSHAKE_TIMEOUT = 60.0 +-# Number of seconds to wait for SSL shutdown to complete +-# The default timeout mimics lingering_time +-DEF SSL_SHUTDOWN_TIMEOUT = 30.0 +-DEF SSL_READ_MAX_SIZE = 256 * 1024 +diff --git a/uvloop/includes/fork_handler.h b/uvloop/includes/fork_handler.h +index 47bbe036..9d3573ae 100644 +--- a/uvloop/includes/fork_handler.h ++++ b/uvloop/includes/fork_handler.h +@@ -1,7 +1,10 @@ ++#ifndef UVLOOP_FORK_HANDLER_H_ ++#define UVLOOP_FORK_HANDLER_H_ ++ + volatile uint64_t MAIN_THREAD_ID = 0; + volatile int8_t MAIN_THREAD_ID_SET = 0; + +-typedef void (*OnForkHandler)(); ++typedef void (*OnForkHandler)(void); + + OnForkHandler __forkHandler = NULL; + +@@ -36,3 +39,4 @@ void setMainThreadID(uint64_t id) { + MAIN_THREAD_ID = id; + MAIN_THREAD_ID_SET = 1; + } ++#endif +diff --git a/uvloop/includes/system.h b/uvloop/includes/system.h +new file mode 100755 +index 00000000..e143bb5c +--- /dev/null ++++ b/uvloop/includes/system.h +@@ -0,0 +1,16 @@ ++#ifndef UVLOOP_SYSTEM_H_ ++#define UVLOOP_SYSTEM_H_ ++#if defined(_WIN32) || defined(MS_WINDOWS) || defined(_MSC_VER) ++#include "Winsock2.h" ++#include "ws2def.h" ++#include "includes/fork_handler.h" ++#else ++#include "arpa/inet.h" ++#include "sys/socket.h" ++#include "sys/un.h" ++#include "unistd.h" ++#include "pthread.h" ++#endif ++#endif ++ ++ +diff --git a/uvloop/includes/system.pxd b/uvloop/includes/system.pxd +index 367fedd1..d1da74ed 100644 +--- a/uvloop/includes/system.pxd ++++ b/uvloop/includes/system.pxd +@@ -1,13 +1,9 @@ + from libc.stdint cimport int8_t, uint64_t + +-cdef extern from "arpa/inet.h" nogil: +- +- int ntohl(int) +- int htonl(int) +- int ntohs(int) +- +- +-cdef extern from "sys/socket.h" nogil: ++cdef extern from "includes/system.h": ++ int ntohl(int) nogil ++ int htonl(int) nogil ++ int ntohs(int) nogil + + struct sockaddr: + unsigned short sa_family +diff --git a/uvloop/includes/uv.pxd b/uvloop/includes/uv.pxd +index 87651306..ddd9738c 100644 +--- a/uvloop/includes/uv.pxd ++++ b/uvloop/includes/uv.pxd +@@ -220,7 +220,7 @@ cdef extern from "uv.h" nogil: + UV_LEAVE_GROUP = 0, + UV_JOIN_GROUP + +- cpdef enum uv_fs_event: ++ cdef enum uv_fs_event: + UV_RENAME = 1, + UV_CHANGE = 2 + +@@ -282,7 +282,7 @@ cdef extern from "uv.h" nogil: + int uv_loop_close(uv_loop_t* loop) + int uv_loop_alive(uv_loop_t* loop) + int uv_loop_fork(uv_loop_t* loop) +- int uv_backend_fd(uv_loop_t* loop) ++ uv_os_fd_t uv_backend_fd(uv_loop_t* loop) + + void uv_update_time(uv_loop_t* loop) + uint64_t uv_now(const uv_loop_t*) +@@ -378,7 +378,7 @@ cdef extern from "uv.h" nogil: + # Pipes + + int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) +- int uv_pipe_open(uv_pipe_t* handle, uv_file file) ++ int uv_pipe_open(uv_pipe_t* handle, uv_os_fd_t file) + int uv_pipe_bind(uv_pipe_t* handle, const char* name) + + void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, +diff --git a/uvloop/loop.pxd b/uvloop/loop.pxd +index 56134733..f90c7041 100644 +--- a/uvloop/loop.pxd ++++ b/uvloop/loop.pxd +@@ -1,15 +1,35 @@ + # cython: language_level=3 + ++cdef extern from *: ++ ''' ++ enum { UV_STREAM_RECV_BUF_SIZE = 256000, ++ SSL_READ_MAX_SIZE = 256 * 1024, // 250kb ++ }; ++ const float SSL_HANDSHAKE_TIMEOUT = 60.0; // Number of seconds to wait for SSL handshake to complete The default timeout matches that of Nginx. ++ const float SSL_SHUTDOWN_TIMEOUT = 30.0; // Number of seconds to wait for SSL shutdown to complete The default timeout mimics lingering_time ++ ''' ++ const bint UV_STREAM_RECV_BUF_SIZE ++ const bint SSL_READ_MAX_SIZE ++ ++ const float SSL_HANDSHAKE_TIMEOUT ++ const float SSL_SHUTDOWN_TIMEOUT ++ ++cdef enum: ++ FLOW_CONTROL_HIGH_WATER = 64 # KiB ++ FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB ++ FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB ++ ++ DNS_PYADDR_TO_SOCKADDR_CACHE_SIZE = 2048 ++ DEBUG_STACK_DEPTH = 10 ++ __PROCESS_DEBUG_SLEEP_AFTER_FORK = 1 ++ LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 ++ + + from .includes cimport uv + from .includes cimport system + + from libc.stdint cimport uint64_t, uint32_t, int64_t + +- +-include "includes/consts.pxi" +- +- + cdef extern from *: + ctypedef int vint "volatile int" + +diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx +index 334d8d50..53e11600 100644 +--- a/uvloop/loop.pyx ++++ b/uvloop/loop.pyx +@@ -43,7 +43,7 @@ from cpython.pycapsule cimport PyCapsule_New, PyCapsule_GetPointer + from . import _noop + + +-include "includes/consts.pxi" ++ + include "includes/stdlib.pxi" + + include "errors.pyx" +@@ -1118,7 +1118,7 @@ cdef class Loop: + + cdef _sock_set_reuseport(self, int fd): + cdef: +- int err ++ int err = 0 + int reuseport_flag = 1 + + err = system.setsockopt( +@@ -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.""" +@@ -2750,7 +2750,7 @@ cdef class Loop: + executable=None, + pass_fds=(), + # For tests only! Do not use in your code. Ever. +- __uvloop_sleep_after_fork=False): ++ uvloop_sleep_after_fork=False): + + # TODO: Implement close_fds (might not be very important in + # Python 3.5, since all FDs aren't inheritable by default.) +@@ -2770,7 +2770,7 @@ cdef class Loop: + if executable is not None: + args[0] = executable + +- if __uvloop_sleep_after_fork: ++ if uvloop_sleep_after_fork: + debug_flags |= __PROCESS_DEBUG_SLEEP_AFTER_FORK + + waiter = self._new_future() +diff --git a/uvloop/sslproto.pxd b/uvloop/sslproto.pxd +index 3da10f00..68e4d572 100644 +--- a/uvloop/sslproto.pxd ++++ b/uvloop/sslproto.pxd +@@ -122,7 +122,7 @@ cdef class SSLProtocol: + # Flow control for writes from APP socket + + cdef _control_app_writing(self, object context=*) +- cdef size_t _get_write_buffer_size(self) ++ cdef size_t _get_write_buffer_size(self) noexcept + cdef _set_write_buffer_limits(self, high=*, low=*) + + # Flow control for reads to APP socket +@@ -134,5 +134,5 @@ cdef class SSLProtocol: + + cdef _control_ssl_reading(self) + cdef _set_read_buffer_limits(self, high=*, low=*) +- cdef size_t _get_read_buffer_size(self) ++ cdef size_t _get_read_buffer_size(self) noexcept + cdef _fatal_error(self, exc, message=*) +diff --git a/uvloop/sslproto.pyx b/uvloop/sslproto.pyx +index 42bb7644..0a437463 100644 +--- a/uvloop/sslproto.pyx ++++ b/uvloop/sslproto.pyx +@@ -861,7 +861,7 @@ cdef class SSLProtocol: + 'protocol': self, + }) + +- cdef size_t _get_write_buffer_size(self): ++ cdef size_t _get_write_buffer_size(self) noexcept: + return self._outgoing.pending + self._write_buffer_size + + cdef _set_write_buffer_limits(self, high=None, low=None): +@@ -903,7 +903,7 @@ cdef class SSLProtocol: + self._incoming_high_water = high + self._incoming_low_water = low + +- cdef size_t _get_read_buffer_size(self): ++ cdef size_t _get_read_buffer_size(self) noexcept: + return self._incoming.pending + + # Flow control for writes to SSL socket + +From 55bab4f7486d9b58ecc4f81120f8f8eaf1099cdd Mon Sep 17 00:00:00 2001 +From: Alan Brooks <12380017+alan-brooks@users.noreply.github.com> +Date: Thu, 28 Dec 2023 16:17:49 +0000 +Subject: [PATCH 2/4] _set_coroutine_debug has args difference in python 3.11 + +--- + uvloop/loop.pyx | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx +index 53e11600..5ca718e4 100644 +--- a/uvloop/loop.pyx ++++ b/uvloop/loop.pyx +@@ -1396,8 +1396,9 @@ cdef class Loop: + def set_debug(self, enabled): + self._debug = bool(enabled) + if self.is_running(): ++ args = (self, self._debug) if sys.version_info < (3, 11) else (self._debug,) + self.call_soon_threadsafe( +- self._set_coroutine_debug, self._debug) ++ self._set_coroutine_debug, *args) + + def is_running(self): + """Return whether the event loop is currently running.""" + +From 95a147f79e1d3685b8f91ddae8a382f4668af27a Mon Sep 17 00:00:00 2001 +From: alan-brooks <12380017+alan-brooks@users.noreply.github.com> +Date: Thu, 28 Dec 2023 19:58:11 +0000 +Subject: [PATCH 3/4] fix tests on python 3.8 + +--- + uvloop/loop.pyx | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx +index 5ca718e4..75b915a9 100644 +--- a/uvloop/loop.pyx ++++ b/uvloop/loop.pyx +@@ -1396,9 +1396,8 @@ cdef class Loop: + def set_debug(self, enabled): + self._debug = bool(enabled) + if self.is_running(): +- args = (self, self._debug) if sys.version_info < (3, 11) else (self._debug,) +- self.call_soon_threadsafe( +- self._set_coroutine_debug, *args) ++ args = ((self, self._debug),) if sys.version_info < (3, 11) else (self._debug,) ++ self.call_soon_threadsafe(self._set_coroutine_debug, *args) + + def is_running(self): + """Return whether the event loop is currently running.""" + +From ca06a743c4472c3629610664760d4538283aebf9 Mon Sep 17 00:00:00 2001 +From: alan-brooks <12380017+alan-brooks@users.noreply.github.com> +Date: Fri, 29 Dec 2023 11:24:19 +0000 +Subject: [PATCH 4/4] fix arg count for wrap() + +--- + uvloop/loop.pxd | 2 +- + uvloop/loop.pyx | 5 ++--- + 2 files changed, 3 insertions(+), 4 deletions(-) + +diff --git a/uvloop/loop.pxd b/uvloop/loop.pxd +index f90c7041..d34ffeb8 100644 +--- a/uvloop/loop.pxd ++++ b/uvloop/loop.pxd +@@ -220,7 +220,7 @@ cdef class Loop: + cdef inline _ceval_process_signals(self) + cdef _invoke_signals(self, bytes data) + +- cdef _set_coroutine_debug(self, bint enabled) ++ cpdef _set_coroutine_debug(self, bint enabled) + + cdef _print_debug_info(self) + +diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx +index 75b915a9..a3eeb605 100644 +--- a/uvloop/loop.pyx ++++ b/uvloop/loop.pyx +@@ -1131,7 +1131,7 @@ cdef class Loop: + if err < 0: + raise convert_error(-errno.errno) + +- cdef _set_coroutine_debug(self, bint enabled): ++ cpdef _set_coroutine_debug(self, bint enabled): + enabled = bool(enabled) + if self._coroutine_debug_set == enabled: + return +@@ -1396,8 +1396,7 @@ cdef class Loop: + def set_debug(self, enabled): + self._debug = bool(enabled) + if self.is_running(): +- args = ((self, self._debug),) if sys.version_info < (3, 11) else (self._debug,) +- self.call_soon_threadsafe(self._set_coroutine_debug, *args) ++ self.call_soon_threadsafe(self._set_coroutine_debug, self._debug) + + def is_running(self): + """Return whether the event loop is currently running.""" diff --git a/SOURCES/604.patch b/SOURCES/604.patch new file mode 100644 index 0000000..26e623a --- /dev/null +++ b/SOURCES/604.patch @@ -0,0 +1,67 @@ +From 118f595c322e387aa4b816d11fa7930f57537278 Mon Sep 17 00:00:00 2001 +From: Karolina Surma +Date: Tue, 30 Apr 2024 14:22:08 +0200 +Subject: [PATCH] Inline _Py_RestoreSignals() from CPython + +private _Py_RestoreSignals() has been moved to CPython internals as of Python 3.13 +See: https://github.com/python/cpython/pull/106400 +Its implementation has been the same in all supported by uvloop Pythons +(3.8+), so the inlining was not conditionalized. +--- + uvloop/includes/compat.h | 20 ++++++++++++++++++++ + uvloop/includes/python.pxd | 4 ++-- + 2 files changed, 22 insertions(+), 2 deletions(-) + +diff --git a/uvloop/includes/compat.h b/uvloop/includes/compat.h +index 7ae39e73..0c408c9e 100644 +--- a/uvloop/includes/compat.h ++++ b/uvloop/includes/compat.h +@@ -1,5 +1,6 @@ + #include + #include ++#include + #include + #include + #include "Python.h" +@@ -83,3 +84,22 @@ int Context_Exit(PyObject *ctx) { + } + + #endif ++ ++/* inlined from cpython/Modules/signalmodule.c ++ * https://github.com/python/cpython/blob/v3.13.0a6/Modules/signalmodule.c#L1931-L1951 ++ * private _Py_RestoreSignals has been moved to CPython internals in Python 3.13 ++ * https://github.com/python/cpython/pull/106400 */ ++ ++void ++_Py_RestoreSignals(void) ++{ ++#ifdef SIGPIPE ++ PyOS_setsig(SIGPIPE, SIG_DFL); ++#endif ++#ifdef SIGXFZ ++ PyOS_setsig(SIGXFZ, SIG_DFL); ++#endif ++#ifdef SIGXFSZ ++ PyOS_setsig(SIGXFSZ, SIG_DFL); ++#endif ++} +diff --git a/uvloop/includes/python.pxd b/uvloop/includes/python.pxd +index 454d5c77..94007e53 100644 +--- a/uvloop/includes/python.pxd ++++ b/uvloop/includes/python.pxd +@@ -11,8 +11,6 @@ cdef extern from "Python.h": + object PyUnicode_EncodeFSDefault(object) + void PyErr_SetInterrupt() nogil + +- void _Py_RestoreSignals() +- + object PyMemoryView_FromMemory(char *mem, ssize_t size, int flags) + object PyMemoryView_FromObject(object obj) + int PyMemoryView_Check(object obj) +@@ -29,3 +27,5 @@ cdef extern from "includes/compat.h": + void PyOS_BeforeFork() + void PyOS_AfterFork_Parent() + void PyOS_AfterFork_Child() ++ ++ void _Py_RestoreSignals() diff --git a/SPECS/python-uvloop.spec b/SPECS/python-uvloop.spec new file mode 100644 index 0000000..10ae59c --- /dev/null +++ b/SPECS/python-uvloop.spec @@ -0,0 +1,310 @@ +## START: Set by rpmautospec +## (rpmautospec version 0.6.5) +## RPMAUTOSPEC: autorelease, autochangelog +%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: + release_number = 5; + base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); + print(release_number + base_release_number - 1); +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} +## END: Set by rpmautospec + +Name: python-uvloop +Version: 0.19.0 +Release: %autorelease +Summary: Ultra fast implementation of asyncio event loop on top of libuv + +License: MIT OR Apache-2.0 +URL: https://github.com/MagicStack/uvloop +Source: %{url}/archive/v%{version}/uvloop-%{version}.tar.gz + +# Fix compatibility with Cython 3. +Patch: https://github.com/MagicStack/uvloop/pull/587.patch + +# Fix build with Python 3.13: _Py_RestoreSignals() has been moved to internals +Patch: https://github.com/MagicStack/uvloop/pull/604.patch + +BuildRequires: gcc +BuildRequires: libuv-devel + +BuildRequires: python3-devel + +# We avoid generating this via the “dev” dependency, because that would bring +# in unwanted documentation dependencies too. +BuildRequires: %{py3_dist pytest} + +%global _description \ +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. + +%description %{_description} + +%package -n python3-uvloop +Summary: %{summary} + +%description -n python3-uvloop %{_description} + +%prep +%autosetup -p1 -n uvloop-%{version} + +# There currently doesn’t appear to be a way to pass through these “build_ext +# options,” so we resort to patching the defaults. Some related discussion +# appears in https://github.com/pypa/setuptools/issues/3896. +# +# always use cython to generate code (and generate a build dependency on it) +sed -i -e "/self.cython_always/s/False/True/" setup.py +# use system libuv +sed -i -e "/self.use_system_libuv/s/False/True/" setup.py + +# To be sure, no 3rd-party stuff +rm -vrf vendor/ + +# - https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters +# - Loosen SemVer pins; we must work with what we have available, especially +# for test dependencies! +sed -r -i \ + -e "s/^([[:blank:]]*)([\"'](flake8|pycodestyle|mypy)\b)/\\1# \\2/" \ + -e 's/~=/>=/' \ + pyproject.toml + +# We don’t have aiohttp==3.9.0b0; see if we can make do with the packaged +# version. +sed -r -i 's/aiohttp==3.9.0b0;/aiohttp>=3.9.0b0;/' pyproject.toml + +# Require Cython 3.x +sed -i 's/\(Cython\)(>=0.29.36,<0.30.0)/\1>=3/' pyproject.toml + +%generate_buildrequires +%pyproject_buildrequires -x test + +%build +%pyproject_wheel + +%install +%pyproject_install +%pyproject_save_files uvloop + +# Don’t ship C sources and headers. +find '%{buildroot}%{python3_sitearch}' -type f -name '*.[ch]' -print -delete +sed -r -i '/\.[ch]$/d' %{pyproject_files} + +%check +%ifarch ppc64le +# ignore tests that fail on ppc64le +ignore="${ignore-} --ignore=tests/test_pipes.py" +%endif + +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters +ignore="${ignore-} --ignore=tests/test_sourcecode.py" + +# Don’t import the “un-built” uvloop from the build directory. +mkdir -p _empty +cd _empty +ln -s ../tests/ . + +# test_getaddrinfo_8 and _9 run getaddrinfo with zero-length inputs +# libuv 1.48.0+ rejects that +# reported as https://github.com/MagicStack/uvloop/issues/596 +# test_create_unix_server_1 fails with Python 3.13 +# https://github.com/MagicStack/uvloop/pull/604 +%pytest -v ${ignore-} -k "not test_getaddrinfo_8 and not test_getaddrinfo_9 and not test_create_unix_server_1" + +%files -n python3-uvloop -f %{pyproject_files} +#license LICENSE-APACHE LICENSE-MIT +%doc README.rst + +%changelog +* Sat Jan 04 2025 Arkady L. Shane - 0.19.0-5 +- Rebuilt for MSVSphere 10 + +## START: Generated by rpmautospec +* Fri Jul 19 2024 Fedora Release Engineering - 0.19.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Fri Jun 07 2024 Python Maint - 0.19.0-4 +- Rebuilt for Python 3.13 + +* Tue Apr 30 2024 Karolina Surma - 0.19.0-3 +- Fix build with Python 3.13 + +* Tue Feb 27 2024 Miro Hrončok - 0.19.0-2 +- Skip tests with zero-length idna inputs, failing on libuv 1.48.0+ + +* Thu Feb 01 2024 Jerry James - 0.19.0-1 +- Version 0.19.0 (rhbz#2245745) +- Replace cython3 patch with upstream PR (fixes rhbz#2259751) + +* Fri Jan 26 2024 Fedora Release Engineering - 0.18.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Mon Jan 22 2024 Fedora Release Engineering - 0.18.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Tue Dec 19 2023 Miro Hrončok - 0.18.0-2 +- Use Cython 3 for building +- Fixes: rhbz#2254040 + +* Mon Oct 16 2023 Benjamin A. Beasley - 0.18.0-1 +- Update to 0.18.0 (close RHBZ#2244190) + +* Mon Oct 16 2023 Benjamin A. Beasley - 0.17.0-11 +- Don’t ship C sources and headers + +* Mon Oct 16 2023 Benjamin A. Beasley - 0.17.0-10 +- Update to pyproject-rpm-macros +- Stop trying to omit uvloop._testbase; it is harmless, and we really do + need it to run the tests against the installed-to-buildroot package. + +* Sun Oct 15 2023 Benjamin A. Beasley - 0.17.0-9 +- Update License to SPDX + +* Fri Sep 22 2023 Carl George - 0.17.0-7 +- Fix building against Python 3.12 +- Switch to building against python3-cython0.29 compat package +- Delete tests that fail on Python 3.12 +- Resolves: rhbz#2226364 rhbz#2220551 rhbz#2203920 + +* Sun Jul 23 2023 Python Maint - 0.17.0-6 +- Rebuilt for Python 3.12 + +* Fri Jul 21 2023 Fedora Release Engineering - 0.17.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Thu Jun 29 2023 Python Maint - 0.17.0-4 +- Rebuilt for Python 3.12 + +* Wed Feb 22 2023 Paul Wouters - 0.17.0-3 +- skip tests for now on ppc64le + +* Tue Feb 21 2023 Paul Wouters - 0.17.0-2 +- new sources for 0.17.0 + +* Tue Feb 21 2023 Paul Wouters - 0.17.0-1 +- Update to 0.17.0 and fix test_libuv_api.py + +* Tue Feb 21 2023 Paul Wouters - 0.15.3-7 +- Revert "Disable tests for now" + +* Fri Jan 20 2023 Fedora Release Engineering - 0.15.3-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Fri Jul 22 2022 Fedora Release Engineering - 0.15.3-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Mon Jun 13 2022 Python Maint - 0.15.3-4 +- Rebuilt for Python 3.11 + +* Fri Jan 21 2022 Fedora Release Engineering - 0.15.3-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Aug 26 2021 Igor Raits - 0.15.3-2 +- Switch to %%autorelease/%%autochangelog + +* Tue Aug 10 2021 Benjamin A. Beasley - 0.15.3-1 +- Update to 0.15.3 + +* Tue Aug 10 2021 Benjamin A. Beasley - 0.15.2-3 +- Drop obsolete python_provide macro + +* Fri Jul 23 2021 Fedora Release Engineering - 0.15.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Wed Jun 09 2021 Carl George - 0.15.2-1 +- Latest upstream 0.15.2 + +* Fri Jun 04 2021 Python Maint - 0.14.0-5 +- Rebuilt for Python 3.10 + +* Wed Jan 27 2021 Fedora Release Engineering - 0.14.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Thu Jan 07 2021 Miro Hrončok - 0.14.0-3 +- Backport Python 3.10+ compatibility + +* Wed Jul 29 2020 Fedora Release Engineering - 0.14.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon Jun 22 2020 Itamar Reis Peixoto - 0.14.0-1 +- python-uvloop 0.14.0 + +* Tue May 26 2020 Miro Hrončok - 0.12.2-9 +- Rebuilt for Python 3.9 + +* Thu Jan 30 2020 Fedora Release Engineering - 0.12.2-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Oct 03 2019 Miro Hrončok - 0.12.2-7 +- Rebuilt for Python 3.8.0rc1 (#1748018) + +* Mon Aug 19 2019 Miro Hrončok - 0.12.2-6 +- Rebuilt for Python 3.8 + +* Fri Jul 26 2019 Fedora Release Engineering - 0.12.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Mon Jun 10 2019 Miro Hrončok - 0.12.2-4 +- Add patch for Python 3.8 support + +* Thu May 02 2019 Igor Gnatenko - 0.12.2-3 +- Disable tests for now + +* Thu May 02 2019 Igor Gnatenko - 0.12.2-2 +- BR: PyOpenSSL + +* Thu May 02 2019 Igor Gnatenko - 0.12.2-1 +- Update to 0.12.2 + +* Sat Feb 02 2019 Fedora Release Engineering - 0.11.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Mon Oct 15 2018 Igor Gnatenko - 0.11.2-3 +- include files which were excluded + +* Wed Aug 08 2018 Igor Gnatenko - 0.11.2-2 +- BR: python3-psutil + +* Wed Aug 08 2018 Igor Gnatenko - 0.11.2-1 +- Update to 0.11.2 + +* Sat Jul 14 2018 Fedora Release Engineering - 0.11.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Sat Jul 07 2018 Igor Gnatenko - 0.11.0-1 +- Update to 0.11.0 + +* Fri Jun 22 2018 Jerry James - 0.10.1-3 +- Try again to fix thread ID type on 32-bit systems. + +* Fri Jun 22 2018 Jerry James - 0.10.1-2 +- Fix thread ID type on 32-bit systems. + +* Fri Jun 22 2018 Jerry James - 0.10.1-1 +- Update to 0.10.1 for python 3.7 support (bz 1556279 and 1584458). + +* Tue Jun 19 2018 Miro Hrončok - 0.8.1-3 +- Rebuilt for Python 3.7 + +* Fri Feb 09 2018 Fedora Release Engineering - 0.8.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Sep 13 2017 Igor Gnatenko - 0.8.1-1 +- Update to 0.8.1 + +* Thu Aug 03 2017 Fedora Release Engineering - 0.8.0-3 +- Rebuilt for + https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 0.8.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Igor Gnatenko - 0.8.0-1 +- Update to 0.8.0 + +* Sat Feb 11 2017 Fedora Release Engineering - 0.7.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Sat Jan 07 2017 Igor Gnatenko - 0.7.2-1 +- Update to 0.7.2 + +* Tue Jan 03 2017 Igor Gnatenko - 0.7.1-1 +- initial import +## END: Generated by rpmautospec