how to use pythran add a myfunction from other py files?

165 views Asked by At

toolsTep.py

def HelloWord():
    print('hello word')

testpythran.py

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

complie pythran testpythran.py

  • CRITICAL :
    I am in trouble. Your input file does not seem to match Pythran's constraints...
  • testpythran.py:

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

when two function in save file and it can find ,in diffrent file it occured those errors

1

There are 1 answers

0
杨钰德 On

When distributing a Python application with Pythran modules, you can either:

declare the module as a regular Python module. After all, they are 100% Python compatible.

declare them as a PythranExtension and Pythran will compile them:

from distutils.core import setup

These two lines are required to be able to use pythran in the setup.py import setuptools setuptools.dist.Distribution(dict(setup_requires='pythran'))

from pythran.dist import PythranExtension, PythranBuildExt setup(..., ext_modules=[PythranExtension("mymodule", ["mymodule.py"])], cmdclass={"build_ext": PythranBuildExt}) PythranBuildExt is optional, but necessary to build extensions with different C++ compilers. It derives from distuil’s build_ext by default, but you can change its base class by using PythranBuildExt[base_cls] instead.

all configuration options supported in .pythranrc can also be passed through the optional config argument, in the form of a list, e.g. config=['compiler.blas=openblas']

from pythran doc.https://pythran.readthedocs.io/en/latest/MANUAL.html