MagicStack/uvloop

uvloop fails to build with Python 3.13-rc1

Closed this issue · 14 comments

  • uvloop version: 0.20.0
  • Python version: 3.13-rc1
  • Platform: Linux (x86)
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: N/A
  • Does uvloop behave differently from vanilla asyncio? How?: N/A

I failed to install uvloop on Python 3.13-rc1 using this command docker run --name python --rm -i -t python:3.13-rc pip install uvloop. It ends up with those errors:

      CC       src/unix/libuv_la-thread.lo
        CC       src/unix/libuv_la-tty.lo
        CC       src/unix/libuv_la-udp.lo
        CC       src/unix/libuv_la-linux.lo
        CC       src/unix/libuv_la-procfs-exepath.lo
        CC       src/unix/libuv_la-proctitle.lo
        CC       src/unix/libuv_la-random-getrandom.lo
        CC       src/unix/libuv_la-random-sysctl-linux.lo
        CCLD     libuv.la
      building 'uvloop.loop' extension
      creating build/temp.linux-x86_64-cpython-313
      creating build/temp.linux-x86_64-cpython-313/uvloop
      gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.13 -I/tmp/pip-install-r84qnrzv/uvloop_79e898f88d434926a381685fb361c382/vendor/libuv/include -c uvloop/loop.c -o build/temp.linux-x86_64-cpython-313/uvloop/loop.o -O2
      uvloop/loop.c:860:1: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
        860 | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
            | ^~~~~~
      uvloop/loop.c: In function ‘__Pyx_Py_UNICODE_strlen’:
      uvloop/loop.c:861:5: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
        861 |     const Py_UNICODE *u_end = u;
            |     ^~~~~
      uvloop/loop.c: In function ‘__Pyx_init_assertions_enabled’:
      uvloop/loop.c:4446:39: warning: implicit declaration of function ‘_PyInterpreterState_GetConfig’; did you mean ‘PyInterpreterState_GetID’? [-Wimplicit-function-declaration]
       4446 |     __pyx_assertions_enabled_flag = ! _PyInterpreterState_GetConfig(__Pyx_PyThreadState_Current->interp)->optimization_level;
            |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |                                       PyInterpreterState_GetID
      uvloop/loop.c:4446:105: error: invalid type argument of ‘->’ (have ‘int’)
       4446 |     __pyx_assertions_enabled_flag = ! _PyInterpreterState_GetConfig(__Pyx_PyThreadState_Current->interp)->optimization_level;
            |                                                                                                         ^~
      uvloop/loop.c: In function ‘__pyx_pymod_exec_loop’:
      uvloop/loop.c:4637:38: warning: implicit declaration of function ‘_PyDict_SetItem_KnownHash’; did you mean ‘_PyDict_GetItem_KnownHash’? [-Wimplicit-function-declaration]
       4637 |     (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
            |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~
      uvloop/loop.c:170726:7: note: in expansion of macro ‘__Pyx_SetNameInClass’
      170726 |   if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_6) < 0) __PYX_ERR(0, 3276, __pyx_L1_error)
             |       ^~~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_set_iter_next’:
      uvloop/loop.c:172859:19: warning: implicit declaration of function ‘_PySet_NextEntry’ [-Wimplicit-function-declaration]
      172859 |         int ret = _PySet_NextEntry(iter_obj, ppos, value, &hash);
             |                   ^~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyUnicode_Join’:
      uvloop/loop.c:174209:13: warning: implicit declaration of function ‘_PyUnicode_FastCopyCharacters’; did you mean ‘PyUnicode_CopyCharacters’? [-Wimplicit-function-declaration]
      174209 |             _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
             |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             |             PyUnicode_CopyCharacters
      uvloop/loop.c: In function ‘__Pyx_PyGen_Send’:
      uvloop/loop.c:174694:13: warning: implicit declaration of function ‘_PyGen_SetStopIterationValue’; did you mean ‘__Pyx_PyGen__FetchStopIterationValue’? [-Wimplicit-function-declaration]
      174694 |             _PyGen_SetStopIterationValue(result);
             |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
             |             __Pyx_PyGen__FetchStopIterationValue
      uvloop/loop.c: In function ‘__Pyx_Coroutine_AwaitableIterError’:
      uvloop/loop.c:175664:5: warning: implicit declaration of function ‘_PyErr_FormatFromCause’ [-Wimplicit-function-declaration]
      175664 |     _PyErr_FormatFromCause(
             |     ^~~~~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyInt_As_int’:
      uvloop/loop.c:177569:27: error: too few arguments to function ‘_PyLong_AsByteArray’
      177569 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
             |                           ^~~~~~~~~~~~~~~~~~~
      In file included from /usr/local/include/python3.13/longobject.h:107,
                       from /usr/local/include/python3.13/Python.h:77,
                       from uvloop/loop.c:22:
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyInt_As_uint64_t’:
      uvloop/loop.c:177765:27: error: too few arguments to function ‘_PyLong_AsByteArray’
      177765 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
             |                           ^~~~~~~~~~~~~~~~~~~
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyInt_As_long’:
      uvloop/loop.c:177999:27: error: too few arguments to function ‘_PyLong_AsByteArray’
      177999 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
             |                           ^~~~~~~~~~~~~~~~~~~
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyInt_As_unsigned_long’:
      uvloop/loop.c:178271:27: error: too few arguments to function ‘_PyLong_AsByteArray’
      178271 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
             |                           ^~~~~~~~~~~~~~~~~~~
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyInt_As_unsigned_int’:
      uvloop/loop.c:178467:27: error: too few arguments to function ‘_PyLong_AsByteArray’
      178467 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
             |                           ^~~~~~~~~~~~~~~~~~~
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~
      uvloop/loop.c: In function ‘__Pyx_PyInt_As_size_t’:
      uvloop/loop.c:178739:27: error: too few arguments to function ‘_PyLong_AsByteArray’
      178739 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
             |                           ^~~~~~~~~~~~~~~~~~~
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for uvloop
Failed to build uvloop
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (uvloop)

#587 will fix this

Great! Thanks @fantix for the update!

I came across this using the Fedora 41 Beta, which ships with Python 3.13. Hopefully 0.21.0 will arrive on PyPI soon.

waiting for this to be merged and live.

can confirm that I could compile and install uvloop on 3.13.0 on ubuntu 22.04lts.

Processing /tmp/uvloop
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: uvloop
  Building wheel for uvloop (pyproject.toml) ... done
  Created wheel for uvloop: filename=uvloop-0.21.0b1-cp313-cp313-linux_x86_64.whl size=4619984 sha256=19fe6d03992624850ed0a41918596dfe97a7ba5413666d345808c5493967818c
  Stored in directory: /tmp/pip-ephem-wheel-cache-bu70wa59/wheels/0e/58/6c/936f66fee135226024fdde3587af7da3d5787645f9ad5f088e
Successfully built uvloop
Installing collected packages: uvloop
Successfully installed uvloop-0.21.0b1```

OK, I have this error too. Also on Ubuntu, but 24.04. Any clues?

Current master builds fine against standard 3.13.0 but failes when python is build with free-threaded/nogil mode with several errors like this:

uvloop/loop.c: In function ‘__Pyx_CyFunction_CallAsMethod’:
uvloop/loop.c:207937:6: error: unknown type name ‘__pyx_vectorcallfunc’; did you mean ‘vectorcallfunc’?
207937 |      __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);

Tested against free-threaded python 3.13.0 installed via asdf using asdf install python 3.13.0t.

3.13.0 still have this bug yeah, especially when installing asyncio.
Solution: I dropped back to 3.12 for Docker img, and it worked.

Would be nice if the fix is installed for 3.13 though

Same error on MacOS 15.0.1 with Python 3.13

I can admit 0.21.0b1 compiles successfully on Ubuntu 24.04 now. I went with my fork of CPython, installed all dependencies and it works.
However:
test_cython_coro_is_coroutine (test_cython.TestCythonIntegration.test_cython_coro_is_coroutine) ... python: Objects/codeobject.c:947: PyCode_Addr2Line: Assertion `addrq >= 0 && addrq < _PyCode_NBYTES(co)' failed.
Aborted (core dumped)
make: *** [Makefile:50: test] Error 134

I also tried to compile with forked Python (which is 3.14 pre-alpha, just 4 days old) and it failed.

@fantix Think you could spin a new release with python 3.13 support?

Yup, on it. I'll promote the current beta into a release.

Think this can now be closed with 0.21.0 out

Yup, please feel free to reopen if 0.21.0 doesn't work.