How do you get cimport to work in Cython?

♀尐吖头ヾ 提交于 2019-12-11 02:27:54

问题


I have a directory structure as so:

/my_module

init.py

A/

  __init__.py

  a.pyx

B/

  __init__.py

  b.pyx

In b.pyx I want to cimport functions from A.a. A regular python import works, but a cimport always fails.

Also, I'm compiling A/ and B/ separately because I couldn't figure out how to put a setup.py in the top module.

Can anyone help here?


回答1:


You have to create a cython declaration file, a .pxd

It shall contain only declarations of classes and functions that you want to import.



来源:https://stackoverflow.com/questions/7295638/how-do-you-get-cimport-to-work-in-cython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!