scipy: BUG: cythonization / compliation failure with development branch of cython

Describe your issue.

cython commit https://github.com/cython/cython/commit/77918c57b5f36bee708f625e2499bf05b23a87f1 in https://github.com/cython/cython/pull/4670 broke scipy installation. This is currently only on cython’s master branch and not in an alpha release yet.

I’m not sure if this is best fixed on the scipy or cython side.

I reported this via back-channels to @rgommers.

Reproducing Code Example

pip install -v --no-build-isolation .

with the development version of cython installed.



### Error message

```shell
The relevant error from compilation is :


  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      if name == NULL:
          name_copy = name
      else:
          name_copy = strdup(name)

      capsule = PyCapsule_New(func, name_copy, &raw_capsule_destructor)
                                               ^
  ------------------------------------------------------------

  /home/tcaswell/source/p/scipy/scipy/scipy/_lib/_ccallback_c.pyx:80:45: Cannot assign type 'void (*)(object) except *' to 'PyCapsule_Destructor'
  Traceback (most recent call last):
    File "/home/tcaswell/source/p/scipy/scipy/scipy/_build_utils/cythoner.py", line 28, in <module>
      main()
    File "/home/tcaswell/source/p/scipy/scipy/scipy/_build_utils/cythoner.py", line 20, in main
      sbp.run(['cython', '-3', '--fast-fail',
    File "/home/tcaswell/.pybuild/bleeding/lib/python3.12/subprocess.py", line 571, in run
      raise CalledProcessError(retcode, process.args,
  subprocess.CalledProcessError: Command '['cython', '-3', '--fast-fail', '--output-file', '/home/tcaswell/source/p/scipy/scipy/.mesonpy-jnf3i747/build/scipy/_lib/_ccallback_c.cpython-312-x86_64-linux-gnu.so.p/_ccallback_c.c', '--include-dir', '/home/tcaswell/source/p/scipy/scipy/.mesonpy-jnf3i747/build', '/home/tcaswell/source/p/scipy/scipy/scipy/_lib/_ccallback_c.pyx']' returned non-zero exit status 1.



### SciPy/NumPy/Python version information

numpy main, cpython main, scipy main

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (29 by maintainers)

Commits related to this issue

Most upvoted comments

Would cython/cython#4552 be backportable with changes?

That very much looks like a 3.0 change (just look at the length of the discussion 😃 ). I can’t say right now if there is something simpler that we could do for 0.29.x. The last (two?) times that we introduced larger changes to 0.29.x always ended with a rollback because we broke someone’s code in unexpected ways. I’d like to avoid doing that again.

However, we certainly do not want to introduce changes in 3.0 that are difficult for users to adapt to, so let’s see what we can come up with.

I have created PoC pull request showing compilable version of scipy using cython3 - #18242

Looks like we will need to add a lot of noexcepts everywhere.

Just a note: Cython 3 has legacy_implicit_noexcept compiler directive which forces exception handling to be backward compatible with 0.29.X Cython. This directive was introduced to help Cython users with migration to Cython 3.