我一直在开发一个Python模块,其中包含用Cython包装的C++扩展。setup.py目前负责扩展模块的构建,并被称为python3 setup.py --build_ext --inplace。
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
srcDir = "../src"
src = ["_MyProject.pyx"] # list of source files
print("source files: {0}".format(src))
modules = [Extension("_MyProject",
src,
language = "c++",
extra_compile_args=["-fopenmp", "-std=c++11", "-O3", "-DNOGTEST"],
extra_link_args=["-fopenmp", "-std=c++11"],
libraries=["MyProjectLib", "log4cxx"],
library_dirs=["../"])]
for e in modules:
e.cython_directives = {"embedsignature" : True}
setup(name="_MyProject",
cmdclass={"build_ext": build_ext},
ext_modules=modules)在Cython模块_MyProject的顶部,有一个从_MyProject导入内容的纯Python模块MyProject。
目前,我通过cd-ing在其目录中使用和测试该模块,并从那里导入它。我需要如何修改我的setup.py,才能将MyProject安装到我的站点包中,并使该包始终保持最新?
发布于 2013-12-29 03:02:47
将参数py_modules = ["MyProject.py",]添加到setup()函数中。
https://stackoverflow.com/questions/20457007
复制相似问题