Call python code from c via cython

后端 未结 3 1598
有刺的猬
有刺的猬 2020-12-05 03:07

So I\'d like to call some python code from c via cython. I\'ve managed to call cython code from c. And I can also call python code from cython. But when I add it all togethe

3条回答
  •  暖寄归人
    2020-12-05 04:00

    Maybe this is not what you want but I got it working by the following changes:

    in quacker.pyx I added

    cdef public int i
    

    To force Cython to generate the .h file.

    An then in the main:

    #include 
    #include "caller.h"
    #include "quacker.h"
    
    int main() {
      Py_Initialize();
      initquacker();
      initcaller();
      call_quack();
      Py_Finalize();
      return 0;
    }
    

提交回复
热议问题