你如何告诉pyximport使用cython --cplus选项? [英] How do you tell pyximport to use the cython --cplus option?

查看:758
本文介绍了你如何告诉pyximport使用cython --cplus选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pyximport是超级方便,但我不知道如何让它参与Cython的C ++语言选项。从命令行,你可以运行 cython --cplus foo.pyx 。如何使用pyximport实现等价?谢谢!

pyximport is super handy but I can't figure out how to get it to engage the C++ language options for Cython. From the command line you'd run cython --cplus foo.pyx. How do you achieve the equivalent with pyximport? Thanks!

推荐答案

使Cython创建C ++文件的一种方法是使用pyxbld文件。例如,创建包含以下内容的 foo.pyxbld

One way to make Cython create C++ files is to use a pyxbld file. For example, create foo.pyxbld containing the following:

def make_ext(modname, pyxfilename):
    from distutils.extension import Extension
    return Extension(name=modname,
                     sources=[pyxfilename],
                     language='c++')

这篇关于你如何告诉pyximport使用cython --cplus选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆