我一直在使用包含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 –