您如何在cython中使用cimport? [英] How do you get cimport to work in Cython?
本文介绍了您如何在cython中使用cimport?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目录结构如下:
/ my_module
/my_module
初始化 .py
A /
__init__.py
a.pyx
B /
__init__.py
b.pyx
在b.pyx中,我想从Aa导入函数
常规的python导入有效,但是cimport总是失败。
In b.pyx I want to cimport functions from A.a. A regular python import works, but a cimport always fails.
此外,由于无法确定A /和B /,所以我分别编译A /和B /如何将setup.py放在顶部模块中。
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?
推荐答案
您必须创建一个cython声明文件,即。 pxd
You have to create a cython declaration file, a .pxd
它应仅包含要导入的类和函数的声明。
It shall contain only declarations of classes and functions that you want to import.
这篇关于您如何在cython中使用cimport?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文