Skip to content

Cython 3.0 compile error #424

@munechika-koyo

Description

@munechika-koyo

Hello!

Because Cython 3.0 was released at last, I tried to compile raysect with it, and encountered some cython compile issues.
They seems to be related to both kdtree2d.pyx and kdtree3d.pyx, and the result when compiled the latter module are shown as follows:

❯ cython kdtree3d.pyx 
warning: /home/koyo/Documents/raysect/source/raysect/core/math/sampler/solidangle.pxd:37:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: /home/koyo/Documents/raysect/source/raysect/core/math/sampler/solidangle.pxd:38:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: kdtree3d.pyx:44:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: kdtree3d.pyx:47:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: kdtree3d.pyx:50:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: kdtree3d.pyx:51:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: kdtree3d.pyx:52:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
warning: kdtree3d.pyx:53:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310

Error compiling Cython file:
------------------------------------------------------------
...
            # upper edge
            edges[upper_index].is_upper_edge = True
            edges[upper_index].value = item.box.upper.get_index(axis)

        # sort
        qsort(<void *> edges, count, sizeof(edge), _edge_compare)
                                                   ^
------------------------------------------------------------

kdtree3d.pyx:344:51: Cannot assign type 'int (const void *, const void *) except? -1 nogil' to 'int (*)(const void *, const void *) noexcept nogil'

According the above error message, I added noexcept at _edge_compare in both kdtree*d.pyx file like:

cdef int _edge_compare(const void *p1, const void *p2) noexcept nogil:

This change seems to resolve the issue.
So, please consider my fix for cython 3.0 compilation.

package version I tired to compile

  • Python 3.10.12
  • Cython 3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions