EADST

Python: Compile .py to .so

1. Set up the environment

pip install cython
yum install python-devel (apt-get install python-devel)
yum install gcc (apt-get install gcc)

2. Create a setup.py file

from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules = cythonize(["your_file_name.py"]))

3. Run this line, the .so file saved in ./build/lib...

python setup.py build_ext

4. Move the .so file to main folder, then import the class or def.

import your_file_name
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
站点统计

本站现有博文242篇,共被浏览290880

本站已经建立1780天!

热门文章
文章归档
回到顶部