直接使用編譯出來的 python modle
井民全, jing, mqjing@gmail.com
Source Files
# 要被編譯的 python module
helloworld.py
def my_python_module():
print("Hello World")
)
|
# cython 編譯 script
setup.py
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize(['helloworld.py',])
)
|
# 按照一般方式呼叫
main_use.py
from helloworld import *
my_python_module()
|
Procedure
Step 1: Compile the Python module
python setup.py build_ext --inplace
Step 2: Copy *.so and the main python code for release purpose
Step 3: Run
python main_use.py