如何使用pythran从其他py文件添加myfunction?

2024-10-04 05:30:55 发布

您现在位置:Python中文网/ 问答频道 /正文

工具步骤.py
def HelloWord():
    print('hello word')

testpythran.py

from calaTools.toolsTep import *
#pythran export callOtherPyFiles()
def callOtherPyFiles():
    HelloWord()

complie pythran testpythran.py

  • 关键
    我有麻烦了。您的输入文件似乎与Pythran的约束不匹配
  • testpythran.py:

    None:None error: Module 'calaTools.toolsTep' not found.

当两个函数在保存文件时,它可以在不同的文件中找到这些错误


Tags: 文件工具pynonehellodef步骤word
1条回答
网友
1楼 · 发布于 2024-10-04 05:30:55

在分发带有Pythran模块的Python应用程序时,您可以:

将该模块声明为常规Python模块。毕竟,它们是100%Python兼容的

将它们声明为PythranExtension,Pythran将编译它们:

从distutils.core导入设置

这两行需要能够在setup.py中使用pythran 导入设置工具 setuptools.dist.Distribution(dict(setup\u需要class='pythran'))

从pythran.dist导入PythranExtension,PythranBuildExt 设置(。。。, ext_modules=[PythranExtension(“mymodule”,“mymodule.py”]), cmdclass={“build_ext”:PythranBuildExt}) PythRANBuffDeXT是可选的,但需要用不同的C++编译器构建扩展。默认情况下,它派生自distuil的build_ext,但您可以改为使用PythranBuildExt[base_cls]来更改其基类

.pythranrc中支持的所有配置选项也可以通过可选的config参数以列表的形式传递,例如config=['compiler.blas=openblas']

来自pythran博士。https://pythran.readthedocs.io/en/latest/MANUAL.html

相关问题 更多 >