我一直在使用包含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
安裝到我的網站包中並讓包始終保持最新?
如果我正確地理解了這個問題,我會使用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 –