2013-12-08 39 views
1

我一直在使用包含Cython包装的C++扩展的Python模块。 setup.py当前处理扩展模块的大楼,并称为python3 setup.py --build_ext --inplace在开发中安装Python/Cython(扩展)模块

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的顶部,有一个纯Python模块MyProject_MyProject进口东西。

目前我使用并测试模块cd -ing进入其目录并从那里导入它。我如何修改我的setup.py,以便我可以将MyProject安装到我的网站包中并让包始终保持最新?

+0

如果我正确地理解了这个问题,我会使用virtualenv和python setup.py开发 - 请参阅http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-installation-of -python-software-with-virtualenv /和http://stackoverflow.com/questions/19048732/python-setup-py-develop-vs-install –

回答

1

将参数py_modules = ["MyProject.py",]添加到您的setup()函数中。

+0

做完之后,我该如何调用'setup.py'来实现所需的安装? – clstaudt