Developing a module (.pyd) for Python in free pascal is fairly easy, see Developing Python Modules with Pascal. But if I want to interface with numpy, this is not that easy.
When using C to interface with numpy, you have to add #include <numpy/arrayobject.h>
to the code, and also call import_array();
in the initialization function.
Is there a way to interface with numpy in pascal?
EDIT1
As mentioned in the comments under @wilberforce answer, the import_array
function which is defined in the header files just imports multiarray.pyd module into the current interpreter and does some checking. It is easily translated into pascal and it works.
The numpy C-API functions are not present initially in pythonXX.dll, so they can't be linked statically. Static or dynamic linking with multiarray.pyd is not working for me.
So the updated question is: Is there a way to access the C-API functions embedded in multiarray.pyd from code which is not C?