windows下将pyx文件编译成pyd文件用于python代码的调用

  1. 编写编译文件的脚本文件setup.py
#!/usr/bin/python
#python version: 2.7.3
#Filename: SetupTestOMP.py
 
# Run as:  
#    python setup.py build_ext --inplace  
   
import sys
import numpy as np
A=sys.path.insert(0, "..")
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext

# ext_module = cythonize("TestOMP.pyx")
ext_module = Extension(
                        "bbox",
            ["bbox.pyx"],
            extra_compile_args=["/openmp"],
            extra_link_args=["/openmp"],
            )

setup(
    cmdclass = {'build_ext': build_ext},
    ext_modules = [ext_module],
    #注意这一句一定要有,不然只编译成C代码,无法编译成pyd文件
    include_dirs=[np.get_include()]
)
  1. 定位到setup.py的文件目录在命令行窗口输入python setup.py build_ext --inplace

你可能感兴趣的:(windows下将pyx文件编译成pyd文件用于python代码的调用)