Dear Cython users/developers,
I am porting an old Python 2.7 codebase to Python 3.9.10, and among things that I have to do is this detail.
I am running this simple piece of code as a test:
import numpy as np
cimport numpy as np
from libc.math cimport fabsf
from libc.float cimport FLT_MAX
cpdef bint test_fabsf(np.float32_t number):
return fabsf(number) < FLT_MAX
With its setup.py file:
from setuptools import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("test_fabsf.pyx", language_level='3str')
)
I get the following:
Compiling test_fabsf.pyx because it changed.
[1/1] Cythonizing test_fabsf.pyx
Error compiling Cython file:
------------------------------------------------------------
...
import numpy as np
cimport numpy as np
from libc.math cimport fabsf
^
------------------------------------------------------------
test_fabsf.pyx:4:0: 'libc\math\fabsf.pxd' not found
Error compiling Cython file:
------------------------------------------------------------
...
from libc.float cimport FLT_MAX
cpdef bint test_fabsf(np.float32_t number):
return fabsf(number) < FLT_MAX
^
------------------------------------------------------------
test_fabsf.pyx:10:11: 'fabsf' is not a constant, variable or function identifier
Traceback (most recent call last):
File "C:\Users\J0514162\MyProjects\Phaser\LinearSolvers\setup_fabsf.py", line 5, in <module>
ext_modules = cythonize("test_fabsf.pyx", language_level='3str')
File "C:\Users\J0514162\WinPython39\WPy64-39100\python-3.9.10.amd64\lib\site-packages\Cython\Build\Dependencies.py", line 1127, in cythonize
cythonize_one(*args)
File "C:\Users\J0514162\WinPython39\WPy64-39100\python-3.9.10.amd64\lib\site-packages\Cython\Build\Dependencies.py", line 1250, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: test_fabsf.pyx
I am not sure I understand the error. I can clearly see fabsf declared in Cython\Includes\numpy\math.pxd at line 64 like this:
float fabsf "npy_fabsf"(float x)
This is on Windows 10 64 bit, with Python 3.9.10 64 bit, NumPy 1.21.5+mkl, Cython 0.29.32. I am sure I am missing something obvious, any suggestion is most welcome :-) .
Thank you.
Andrea.