grpc fails to build with Python 3.13.0a1. gcc ... -fPIC -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"Python\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.48.4\" -DOPENSSL_NO_ASM=1 -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 "-DPyMODINIT_FUNC=extern \"C\" __attribute__((visibility (\"default\"))) PyObject*" -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -I/usr/include -Ithird_party/address_sorting/include -I/usr/include -I/usr/include/re2 -I/usr/include/openssl -Ithird_party/upb -Isrc/core/ext/upb-generated -Isrc/core/ext/upbdefs-generated -Ithird_party/xxhash -I/usr/include -I/usr/include/python3.13 -c src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc -o python_build/temp.linux-x86_64-cpython-313/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.o -std=c++17 -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-function-declaration’ is not valid for C++ cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-int’ is not valid for C++ src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘PyObject* __pyx_f_4grpc_7_cython_6cygrpc__initialize()’: src/python/grpcio/grpc/_cython/cygrpc.cpp:126486:10: error: ‘PyEval_InitThreads’ was not declared in this scope; did you mean ‘PyEval_SaveThread’? 126486 | (void)(PyEval_InitThreads()); | ^~~~~~~~~~~~~~~~~~ | PyEval_SaveThread According to https://docs.python.org/3.13/whatsnew/3.13.html: Remove PyEval_InitThreads() and PyEval_ThreadsInitialized() functions, deprecated in Python 3.9. Since Python 3.7, Py_Initialize() always creates the GIL: calling PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized() always returned non-zero. (Contributed by Victor Stinner in https://github.com/python/cpython/issues/105182.) https://docs.python.org/3.13/whatsnew/3.13.html There is also: src/python/grpcio/grpc/_cython/cygrpc.cpp: At global scope: src/python/grpcio/grpc/_cython/cygrpc.cpp:1360:31: error: standard attributes in middle of decl-specifiers 1360 | #define CYTHON_UNUSED [[maybe_unused]] | ^ For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06588087-grpc/ For all our attempts to build grpc with Python 3.13, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/grpc/ Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.13: https://copr.fedorainfracloud.org/coprs/g/python/python3.13/ Let us know here if you have any questions. Python 3.13 is planned to be included in Fedora 41. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13. A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon. We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.
I am trying with: diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index ca1b4c8..1a49b42 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -79,14 +79,9 @@ include "_cygrpc/aio/server.pyx.pxi" # # initialize gRPC # -cdef extern from "Python.h": - - int PyEval_InitThreads() - cdef _initialize(): # We have Python callbacks called by c-core threads, this ensures the GIL # is initialized. - PyEval_InitThreads() grpc_set_ssl_roots_override_callback( <grpc_ssl_roots_override_callback>ssl_roots_override_callback) As for the other error, no idea yet.
(In reply to Miro Hrončok from comment #1) > I am trying with: > > […] Support for this approach: https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads > Deprecated function which does nothing. > > In Python 3.6 and older, this function created the GIL if it didn’t exist. > > Changed in version 3.9: The function now does nothing. > > Changed in version 3.7: This function is now called by Py_Initialize(), so you don’t have to call it yourself anymore. > > Changed in version 3.2: This function cannot be called before Py_Initialize() anymore. > > Deprecated since version 3.9. Since even EPEL9 has Python 3.9, I agree that this is 100% safe to remove.
The other thing seems like a CYthon problem to me, reported as https://github.com/cython/cython/issues/5790
I am testing a build with Cython patched via https://github.com/cython/cython/pull/5791 (and with PyEval_InitThreads() removed from grpc). If it succeeds, could you please commit the PyEval_InitThreads() removal? I'll handle Cython itself.
The build is in https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/grpc/ I need to go offline and I might not be available for the rest fo this week.
(In reply to Miro Hrončok from comment #4) > I am testing a build with Cython patched via > https://github.com/cython/cython/pull/5791 (and with PyEval_InitThreads() > removed from grpc). > > If it succeeds, could you please commit the PyEval_InitThreads() removal? > I'll handle Cython itself. Sure. The call is still present in upstream master, so I’ll try to send a PR and apply it as a patch.
FEDORA-2023-b55393bec7 has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-b55393bec7
FEDORA-2023-b55393bec7 has been pushed to the Fedora 40 stable repository. If problem still persists, please make note of it in this bug report.
> I'll handle Cython itself. https://src.fedoraproject.org/rpms/Cython/pull-request/51