Python的打包和部署仍然是我们许多人的痛点。只是没有一颗银弹。以下是几种方法:
1。OpenCV构建方法OpenCV generates these wrapper functions automatically from the C++
headers using some Python scripts which are located in
modules/python/src2.
基本上,它解析头文件并在需要时生成static PyObject关键字。一旦适当地创建了头,它只需调用python setup。老实说,这可能有用,但我不建议采用这种方法。在
2。生成文件
如果已经使用Makefile,只需创建一个规则来放置lib。例如,根据我自己的代码:setup.pyfrom distutils.core import setup, Extension
setup(name='sha1_hmac', version='1.0', \
ext_modules=[Extension('sha1_hmac',
library_dirs=['C:\MinGW\lib'],
sources= ['../tools/sha1.c','sha1_hmac.c'])])Makefile
^{pr2}$
3。现代部署工具
有几种新的工具可以部署python应用程序,即wheels,它们似乎很有吸引力。我不使用它,但它看起来可以缓解您的捆绑问题:
一旦它wheeled,就可以这样安装它:pip install some-package.whl