如何在MacOS X python轮中包含brew的依赖项?

时间:2016-08-01 06:11:16

标签: python macos machine-learning compilation caffe

我在Mac OS X上构建了一个应用程序Caffe。它在brew中有许多依赖项,一个通用的包管理器,而构建工件是一个可导入的Python模块。

我相信我可以把这个模块打包成一个轮子,一个模块包。但我也想发送所有依赖项。您可以在此处查看主要的二进制依赖项:

$ otool -L /Users/bberman/Library/Python/2.7/lib/python/site-packages/caffe/_caffe.so

/Users/bberman/Library/Python/2.7/lib/python/site-packages/caffe/_caffe.so:
    python/caffe/_caffe.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/bberman/Library/Python/2.7/lib/python/site-packages/caffe/libcaffe.so.1.0.0-rc3 (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
    @rpath/libcudart.7.5.dylib (compatibility version 0.0.0, current version 7.5.27)
    @rpath/libcublas.7.5.dylib (compatibility version 0.0.0, current version 7.5.27)
    @rpath/libcurand.7.5.dylib (compatibility version 0.0.0, current version 7.5.27)
    /usr/local/opt/glog/lib/libglog.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/gflags/lib/libgflags.2.dylib (compatibility version 2.0.0, current version 2.1.2)
    /usr/local/opt/protobuf/lib/libprotobuf.9.dylib (compatibility version 10.0.0, current version 10.1.0)
    /usr/local/opt/boost159/lib/libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/opt/boost159/lib/libboost_filesystem.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
    /usr/local/opt/hdf5/lib/libhdf5_hl.10.dylib (compatibility version 11.0.0, current version 11.2.0)
    /usr/local/opt/hdf5/lib/libhdf5.10.dylib (compatibility version 12.0.0, current version 12.0.0)
    /usr/local/opt/leveldb/lib/libleveldb.1.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/opt/snappy/lib/libsnappy.1.dylib (compatibility version 5.0.0, current version 5.0.0)
    /usr/local/opt/lmdb/lib/liblmdb.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/opt/opencv/lib/libopencv_core.2.4.dylib (compatibility version 2.4.0, current version 2.4.13)
    /usr/local/opt/opencv/lib/libopencv_highgui.2.4.dylib (compatibility version 2.4.0, current version 2.4.13)
    /usr/local/opt/opencv/lib/libopencv_imgproc.2.4.dylib (compatibility version 2.4.0, current version 2.4.13)
    /usr/local/opt/boost159/lib/libboost_thread-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libcudnn.5.dylib (compatibility version 0.0.0, current version 5.1.3)
    /usr/local/opt/boost-python159/lib/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
    /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)

您可以在此处查看这些构建步骤:https://gist.github.com/doctorpangloss/f8463bddce2a91b949639522ea1dcbe4

Caffee是一个复杂的库,通过Python模块使用它非常有帮助。我怎么能把所有这些碎片装在轮子里?

2 个答案:

答案 0 :(得分:0)

如果你想创建一个独立的可执行文件(在python项目之外),你可能想要使用py2app

Here您可以找到所有可执行应用程序的文档 注意:py2exe与windows相同

我可能会误解你的问题,如果是的话,我想知道:)

答案 1 :(得分:0)

添加到Armitage.apk的答案,使用py2app一个如何将python文件实际转换为独立应用程序的示例,本教程非常棒: https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/