"Suggest adding noexcept to type ..." error when compiling grpcio into p4a?

535 views Asked by At

I have been facing into several different errors trying to compile grpcio into my p4a project, with the recent most one coming from my try at compiling it as a CppCompiledComponentsPythonRecipe:

    Traceback (most recent call last):
      File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1256, in <module>
        main()
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
        ToolchainCL()
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 685, in __init__
        getattr(self, command)(args)
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 104, in wrapper_func
        build_dist_from_args(ctx, dist, args)
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 163, in build_dist_from_args
        build_recipes(build_order, python_modules, ctx,
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 504, in build_recipes
        recipe.build_arch(arch)
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 983, in build_arch
        self.build_compiled_components(arch)
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 994, in build_compiled_components
        shprint(hostpython, 'setup.py', self.build_cmd, '-v',
      File "/mnt/d/PycharmProject/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
        for line in output:
      File "/home/fatkrab/.local/lib/python3.10/site-packages/sh.py", line 915, in next
        self.wait()
      File "/home/fatkrab/.local/lib/python3.10/site-packages/sh.py", line 845, in wait
        self.handle_command_exit_code(exit_code)
      File "/home/fatkrab/.local/lib/python3.10/site-packages/sh.py", line 869, in handle_command_exit_code
        raise exc
    sh.ErrorReturnCode_1:

      RAN: /mnt/d/PycharmProject/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a_x86_x86_64/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v

      STDOUT:
    Cython-generated files are missing...
    Compiling src/python/grpcio/grpc/_cython/cygrpc.pyx because it changed.
    [1/1] Cythonizing src/python/grpcio/grpc/_cython/cygrpc.pyx
    /mnt/d/PycharmProject/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a_x86_x86_64/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /mnt/d/PycharmProject/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a_x86_x86_64/build/other_builds/grpcio/x86__ndk_target_28/grpcio/src/python/grpcio/grpc/_cython/cygrpc.pxd
      tree = Parsing.p_module(s, pxd, full_module_name)
    warning: src/python/grpcio/grpc/_cython/cygrpc.pxd:40:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
    warning: src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pxd.pxi:19:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
    warning: src/python/grpcio/grpc/_cython/cygrpc.pyx:63:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
    warning: src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:37:36: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
    warning: src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:51:44: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
    warning: src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:58:43: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
    warning: src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi:24:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi:68:5: Exception check on '_destroy' will always require the GIL to be acquired.
    Possible solutions:
            1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
            2. Use an 'int' return type on the function to allow an error code to be returned.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
      # C-core assumes ownership of c_options
      credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options)
      return credentials

    cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapper(
            void* user_data, grpc_ssl_server_certificate_config **config) except noexcept with gil:
                                                                                 ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi:317:77: undeclared name not builtin: noexcept

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
      # C-core assumes ownership of c_options
      credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options)
      return credentials

    cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapper(
            void* user_data, grpc_ssl_server_certificate_config **config) except noexcept with gil:
                                                                                 ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi:317:77: Not allowed in a constant expression

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
      # C-core assumes ownership of c_options
      credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options)
      return credentials

    cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapper(
            void* user_data, grpc_ssl_server_certificate_config **config) except noexcept with gil:
                                                                                 ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi:317:77: Exception value must be constant
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi:21:5: Exception check on '_copy_slice' will always require the GIL to be acquired. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi:26:5: Exception check on '_slice_from_bytes' will always require the GIL to be acquired. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi:20:5: Exception check on 'ssl_roots_override_callback' will always require the GIL to be acquired. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:37:5: Exception check on '__prefork' will always require the GIL to be acquired.
    Possible solutions:
            1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
            2. Use an 'int' return type on the function to allow an error code to be returned.
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:51:5: Exception check on '__postfork_parent' will always require the GIL to be acquired.
    Possible solutions:
            1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
            2. Use an 'int' return type on the function to allow an error code to be returned.
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:58:5: Exception check on '__postfork_child' will always require the GIL to be acquired.
    Possible solutions:
            1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
            2. Use an 'int' return type on the function to allow an error code to be returned.
    performance hint: src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi:30:9: Exception check on '_unified_socket_write' will always require the GIL to be acquired.
    Possible solutions:
            1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
            2. Use an 'int' return type on the function to allow an error code to be returned.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        return 1
      else:
        return 0

    cdef grpc_arg_pointer_vtable default_vtable
    default_vtable.copy = &_copy_pointer
                          ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi:34:22: Cannot assign type 'void *(*)(void *) except? NULL' to 'void *(*)(void *) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void *(void *) except? NULL'.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
      else:
        return 0

    cdef grpc_arg_pointer_vtable default_vtable
    default_vtable.copy = &_copy_pointer
    default_vtable.destroy = &_destroy_pointer
                             ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi:35:25: Cannot assign type 'void (*)(void *) except *' to 'void (*)(void *) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void *) except *'.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        return 0

    cdef grpc_arg_pointer_vtable default_vtable
    default_vtable.copy = &_copy_pointer
    default_vtable.destroy = &_destroy_pointer
    default_vtable.cmp = &_compare_pointer
                         ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi:36:21: Cannot assign type 'int (*)(void *, void *) except? -1' to 'int (*)(void *, void *) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (void *, void *) except? -1'.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    def fork_handlers_and_grpc_init():
        grpc_init()
        if _GRPC_ENABLE_FORK_SUPPORT:
            with _fork_state.fork_handler_registered_lock:
                if not _fork_state.fork_handler_registered:
                    pthread_atfork(&__prefork, &__postfork_parent, &__postfork_child)
                                   ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:93:31: Cannot assign type 'void (*)(void) except * nogil' to 'void (*)(void) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void) except * nogil'.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    def fork_handlers_and_grpc_init():
        grpc_init()
        if _GRPC_ENABLE_FORK_SUPPORT:
            with _fork_state.fork_handler_registered_lock:
                if not _fork_state.fork_handler_registered:
                    pthread_atfork(&__prefork, &__postfork_parent, &__postfork_child)
                                               ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:93:43: Cannot assign type 'void (*)(void) except * nogil' to 'void (*)(void) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void) except * nogil'.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    def fork_handlers_and_grpc_init():
        grpc_init()
        if _GRPC_ENABLE_FORK_SUPPORT:
            with _fork_state.fork_handler_registered_lock:
                if not _fork_state.fork_handler_registered:
                    pthread_atfork(&__prefork, &__postfork_parent, &__postfork_child)
                                                                   ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi:93:63: Cannot assign type 'void (*)(void) except * nogil' to 'void (*)(void) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void) except * nogil'.

    Error compiling Cython file:
    ------------------------------------------------------------
    ...


    cdef class CallbackWrapper:

       def __cinit__(self, object future, object loop, CallbackFailureHandler failure_handler):
           self.context.functor.functor_run = self.functor_run
                                                  ^
    ------------------------------------------------------------

    src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pyx.pxi:36:46: Cannot assign type 'void (grpc_completion_queue_functor *, int) except *' to 'void (*)(grpc_completion_queue_functor *, int) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (grpc_completion_queue_functor *, int) except *'.
    Traceback (most recent call last):
      File "setup.py", line 478, in <module>
        CYTHON_EXTENSION_MODULES, need_cython = cython_extensions_and_necessity()
      File "setup.py", line 473, in cython_extensions_and_necessity
        return commands.try_cythonize(extensions,
      File "/mnt/d/PycharmProject/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a_x86_x86_64/build/other_builds/grpcio/x86__ndk_target_28/grpcio/src/python/grpcio/commands.py", line 191, in try_cythonize
        return Cython.Build.cythonize(
      File "/mnt/d/PycharmProject/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a_x86_x86_64/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
        cythonize_one(*args)
      File "/mnt/d/PycharmProject/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a_x86_x86_64/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
        raise CompileError(None, pyx_file)
    Cython.Compiler.Errors.CompileError: src/python/grpcio/grpc/_cython/cygrpc.pyx

I have tried several different solutions. Am I just doing something wrong? My current Cython version is 3.0.5, and the version of grpcio I am trying to compile is 1.53.0. Is there something I am not doing correctly?

0

There are 0 answers