2013-12-08 44 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