Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cython 3.0 support #74

Closed
modelonrobinandersson opened this issue Nov 3, 2023 · 0 comments · Fixed by #81, #82 or #83
Closed

Cython 3.0 support #74

modelonrobinandersson opened this issue Nov 3, 2023 · 0 comments · Fixed by #81, #82 or #83
Assignees
Labels
enhancement New feature or request

Comments

@modelonrobinandersson
Copy link
Member

Assimulo does not build with Cython 3. We should add support for that.

Build error I got when trying with latest Cython available with Python 3.8:

[1/1] Cythonizing assimulo/explicit_ode.pyx
/opt/venv/lib/python3.8/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: /opt/build/wheel_build/build/assimulo/explicit_ode.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
        cdef N.ndarray[double, mode="c", ndim=1] g_high_c = N.empty(n_g, dtype = N.double)
        cdef N.ndarray[double, mode="c", ndim=1] y_high_c = N.array(y_high)
        cdef int nstatefcns = 0
        cdef int ret = explicit_ode.f_event_locator(len(y_high), n_g, 1.e-13, t_low, &t_high,
                                                    &y_high_c[0], &g_low_c[0], &g_mid_c[0], &g_high_c[0],
                                                    callback_event, <void*>self.event_func,
                                                    ^
------------------------------------------------------------

assimulo/explicit_ode.pyx:345:52: Cannot assign type 'int (int, int, double, double *, double *, void *) except? -1' to 'FP_event_func'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (int, int, double, double *, double *, void *) except? -1'.

Error compiling Cython file:
------------------------------------------------------------
...
        cdef N.ndarray[double, mode="c", ndim=1] y_high_c = N.array(y_high)
        cdef int nstatefcns = 0
        cdef int ret = explicit_ode.f_event_locator(len(y_high), n_g, 1.e-13, t_low, &t_high,
                                                    &y_high_c[0], &g_low_c[0], &g_mid_c[0], &g_high_c[0],
                                                    callback_event, <void*>self.event_func,
                                                    callback_interp, <void*>self.interpolate,
                                                    ^
------------------------------------------------------------

assimulo/explicit_ode.pyx:346:52: Cannot assign type 'int (int, double, double *, void *) except? -1' to 'FP_interpolation'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (int, double, double *, void *) except? -1'.
Traceback (most recent call last):
  File "setup.py", line 652, in <module>
    ext_list = prepare.cython_extensionlists()
  File "setup.py", line 472, in cython_extensionlists
    ext_list = cythonize([os.path.join("assimulo", "explicit_ode.pyx")],
  File "/opt/venv/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
    cythonize_one(*args)
  File "/opt/venv/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: assimulo/explicit_ode.pyx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment