我正在调试python2.7的C扩展。我使用python2.7调试构建。我用setuptools
构建我的项目,我的setup.py
有这样的行:
ext_modules=[Extension("my.extension",
["my/_extension.c"])]
当我出于某种原因调用python setup.py install
时,扩展将编译成后缀为_d
的文件,之后,在Python中,我不能执行import my.extension
,只能执行import my.extension_d
。我得到的是:
当然,我的扩展没有initextension_d
,它只有initextension
函数。在
这非常不方便,因为我必须更改一些代码,并在imports和其他东西中添加这个_d
后缀。在
可以关闭这个后缀的前缀吗?或者如何以其他方式处理这个问题?也许有一些“官方”的方式?在
我用的是Ubuntu Linux。在
只需在构建C扩展时禁用调试模式。 或者,如果您想保留调试信息,请临时禁用
_DEBUG
宏:对于完整的代码示例,您可以看看full version如何boost.python包括
python.h
。在来自
build_ext.py
的distutils源文件的注释:对于C扩展也是一样的,所以应该不会有任何问题。但既然有一个,也可以去掉
_d
后缀:或者暂时禁用调试:
^{pr2}$别忘了在
setup
内设置cmdclass
:我自己并不是在使用Windows,所以这只是一个猜测,但也许你在混合Python的调试和发布部分。在
要解决这个问题,可以在C模块函数中定义
相关问题 更多 >
编程相关推荐