如何从没有conda的源安装Bob

时间:2018-06-11 17:27:13

标签: python python-bob

Bob使用Party.joins(:name, :expired_names).to_sql => "SELECT \"parties\".* FROM \"parties\" INNER JOIN \"party_names\" ON \"party_names\".\"party_id\" = \"parties\".\"id\" INNER JOIN \"expired_names\" ON \"expired_names\".\"party_id\" = \"parties\".\"id\"" 向其用户推荐其install个包, 但我不想使用conda。如何从源代码安装它?

2 个答案:

答案 0 :(得分:4)

解释

首先,使用conda来安装Bob更容易,并且是支持安装Bob的方法。在继续之前,请再次考虑使用conda来安装Bob。 Bob是用C ++和Python混合编写的,并链接到许多不同的C / C ++库,Conda是一个与语言无关的二进制包管理器,可以处理所有这些。

如果要从源安装Bob,首先需要手动安装其依赖项。每个包的依赖关系列在每个Bob包的conda配方中。从其conda配方中,您必须安装(如果存在)requirements:buildrequirements:hostrequirements:runtest:requires。这些包是conda包而不是pip包;其中一些可能是pip包(名称可能不同),其中一些可能只是一个C / C ++库,您应该使用系统的包管理器(或从源代码)安装。

例如,bob.extension的conda配方是here

requirements:
  host:
    - python {{ python }}
    - setuptools {{ setuptools }}
  run:
    - python
    - setuptools
    - click
    - click-plugins

test:
  requires:
    - bob-devel {{ bob_devel }}.*
    - nose
    - coverage
    - sphinx
    - sphinx_rtd_theme
    - boost
    - cmake
    - pkg-config
    - freetype
    - libblitz
    - numpy
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - bob.buildout

解析此配方意味着您需要安装: 首先是系统的包管理器boostcmakepkg-configfreetypelibblitzC and C++ compilers,可能numpy然后使用pip安装clickclick-pluginsnosecoveragesphinxsphinx_rtd_themebob.buildout。 (您还可以查看Bob软件包的requirements.txttest-requirements.txt以查找依赖项的pip包名称,但可能无法更新以匹配其conda配方)。 bob-devel是一个conda元数据包,在不使用conda时不需要安装。

这将设置您的环境以准备编译(如果需要),安装和测试bob.extension。设置环境后,您可以使用pip来安装bob.extension

pip install bob.extension

然后,您需要按Bob包依赖项的顺序安装下一个Bob包。正如您所看到的,这可能非常耗时,但这是实现它的唯一方法,可以在Bob的软件包开发及其依赖关系发生变化时起作用。

说明

这些说明将帮助您安装大多数包含难以安装的C ++代码的Bob软件包。安装这些软件包后,您很可能可以使用pip安装其余的Bob软件包。

依赖关系

您需要先使用系统的软件包管理器安装Bob软件包依赖项。

+-------------+------+-------------------------+---------------------+
| Library     | Min. | License                 | Notes               |
|             | Vers |                         |                     |
|             | io   |                         |                     |
|             | n    |                         |                     |
+=============+======+=========================+=====================+
| Std. C/C++  | any  | Depends on the compiler | Required by all     |
| Libraries   |      |                         | packages with C/C++ |
|             |      |                         | bindings            |
+-------------+------+-------------------------+---------------------+
| `Blitz++ <h | 0.10 | `Artistic-2.0 <http://w | Required by all     |
| ttp://www.o |      | ww.opensource.org/licen | packages with C/C++ |
| onumerics.o |      | ses/Artistic-2.0>`__    | bindings            |
| rg/blitz>`_ |      | or LGPLv3+ or GPLv3+    |                     |
| _           |      |                         |                     |
+-------------+------+-------------------------+---------------------+
| `Lapack <ht | any  | BSD-style               | Required by         |
| tp://www.ne |      |                         | ``bob.math``        |
| tlib.org/la |      |                         |                     |
| pack>`__    |      |                         |                     |
+-------------+------+-------------------------+---------------------+
| `Python <ht | 2.5  | `Python-2.0 <http://www | Required by all     |
| tp://www.py |      | .opensource.org/license | packages            |
| thon.org>`_ |      | s/Python-2.0>`__        |                     |
| _           |      |                         |                     |
+-------------+------+-------------------------+---------------------+
| `Boost <htt | 1.34 | `BSL-1.0 <http://www.op | Required by all     |
| p://www.boo |      | ensource.org/licenses/B | packages with C/C++ |
| st.org>`__  |      | SL-1.0>`__              | bindings            |
+-------------+------+-------------------------+---------------------+
| `HDF5 <http | 1.8. | `HDF5                   | Required by all I/O |
| ://www.hdfg | 4    | License <ftp://ftp.hdfg | operations (direct  |
| roup.org/HD |      | roup.org/HDF5/current/s | or indirect         |
| F5>`__      |      | rc/unpacked/COPYING>`__ | dependencies to     |
|             |      | (BSD-like, 5 clauses)   | ``bob.io.base``)    |
+-------------+------+-------------------------+---------------------+
| `libpng <ht | 1.2. | `libpng                 | Required by all     |
| tp://libpng | 42   | license <http://www.lib | packages that do    |
| .org/pub/pn | ?    | png.org/pub/png/src/lib | image I/O and       |
| g/libpng.ht |      | png-LICENSE.txt>`__     | manipulation        |
| ml>`__      |      |                         | (depend directly or |
|             |      |                         | indirectly on       |
|             |      |                         | ``bob.io.image``)   |
+-------------+------+-------------------------+---------------------+
| `libtiff <h | 3.9. | BSD-style               | Required by all     |
| ttp://www.r | 2    |                         | packages that do    |
| emotesensin |      |                         | image I/O and       |
| g.org/libti |      |                         | manipulation        |
| ff/>`__     |      |                         | (depend directly or |
|             |      |                         | indirectly on       |
|             |      |                         | ``bob.io.image``)   |
+-------------+------+-------------------------+---------------------+
| `giflib <ht | 4.1. | `MIT <http://www.openso | Required by all     |
| tp://giflib | 6-9  | urce.org/licenses/MIT>` | packages that do    |
| .sourceforg |      | __                      | image I/O and       |
| e.net/>`__  |      |                         | manipulation        |
|             |      |                         | (depend directly or |
|             |      |                         | indirectly on       |
|             |      |                         | ``bob.io.image``)   |
+-------------+------+-------------------------+---------------------+
| `libjpeg <h | 6.2? | `GPL-2.0 <http://www.op | Required by all     |
| ttp://libjp |      | ensource.org/licenses/G | packages that do    |
| eg.sourcefo |      | PL-2.0>`__              | image I/O and       |
| rge.net/>`_ |      | or later (also          | manipulation        |
| _           |      | commercial)             | (depend directly or |
|             |      |                         | indirectly on       |
|             |      |                         | ``bob.io.image``)   |
+-------------+------+-------------------------+---------------------+
| `FFMpeg <ht | 0.5  | `LGPL-2.1 <http://www.o | Required by all     |
| tp://ffmpeg | (ffm | pensource.org/licenses/ | packages that do    |
| .org>`__    | pe   | LGPL-2.1>`__            | video I/O and       |
| or          | g)   | or later, or            | manipulation        |
| `libAV <htt | or   | `GPL-2.0 <http://www.op | (depend directly or |
| p://libav.o | 0.8  | ensource.org/licenses/G | indirectly on       |
| rg>`__      | (lib | PL-2.0>`__              | ``bob.io.video``)   |
|             | av   | or later                |                     |
|             | )    |                         |                     |
+-------------+------+-------------------------+---------------------+
| `MatIO <htt | 1.3. | `BSD-2-Clause <http://w | Required by all     |
| p://matio.s | 3?   | ww.opensource.org/licen | packages that do    |
| ourceforge. |      | ses/BSD-2-Clause>`__    | Matlab I/O and      |
| net>`__     |      |                         | manipulation        |
|             |      |                         | (depend directly or |
|             |      |                         | indirectly on       |
|             |      |                         | ``bob.io.matlab``)  |
+-------------+------+-------------------------+---------------------+
| `VLFeat <ht | 0.9. | `BSD-2-Clause <http://w | Required by         |
| tp://www.vl | 14   | ww.opensource.org/licen | ``bob.ip.base`` and |
| feat.org/>` |      | ses/BSD-2-Clause>`__    | all dependents      |
| __          |      |                         |                     |
+-------------+------+-------------------------+---------------------+
| `LIBSVM <ht | 2.89 | `BSD-3-Clause <http://w | Required by         |
| tp://www.cs | +    | ww.opensource.org/licen | ``bob.learn.libsvm` |
| ie.ntu.edu. |      | ses/BSD-3-Clause>`__    | `                   |
| tw/~cjlin/l |      |                         | and all dependents  |
| ibsvm/>`__  |      |                         |                     |
+-------------+------+-------------------------+---------------------+
| `CMake <htt | 2.8  | `BSD-3-Clause <http://w | Required by all     |
| p://www.cma |      | ww.opensource.org/licen | packages with C/C++ |
| ke.org>`__  |      | ses/BSD-3-Clause>`__    | bindings. **Use at  |
|             |      |                         | least CMake 2.8.12  |
|             |      |                         | on Mac OS X**.      |
+-------------+------+-------------------------+---------------------+
| `pkg-config | any  | `GPL-2.0 <http://www.op | Required to find    |
|  <http://ww |      | ensource.org/licenses/G | dependencies while  |
| w.freedeskt |      | PL-2.0>`__              | building bob        |
| op.org/wiki |      |                         | packages.           |
| /Software/p |      |                         |                     |
| kg-config/> |      |                         |                     |
| `__         |      |                         |                     |
+-------------+------+-------------------------+---------------------+

安装依赖项后,您可以使用pip从源代码安装。

可以使用pip全局或私有安装软件包 virtualenv,如果这是您喜欢Python工作环境的方式。您 需要手动安装所需的所有软件包(直接或间接), 因为pip / setuptools目前无法连贯地安装Python 相互依赖的软件包用于构建,例如很多情况 包。

例如,在新创建的虚拟中安装bob.io.image 环境,这是要执行的命令序列:

$ pip install numpy
$ pip install bob.extension
$ pip install bob.blitz
$ pip install bob.core
$ pip install bob.io.base
$ pip install bob.io.image

每个pip命令必须单独执行,尊重包间 依赖性。

以下按预期工作:

$ #Do not do this:
$ pip install numpy bob.io.image

核心包的依赖性可归纳为7层和 以下脚本可用于使用pip安装所有核心软件包:

$ bash pip_install_bob.sh
-------------------------
#!/bin/bash
set -e

get_layer() {
case $1 in
 1)
   packages=("bob.extension")
   ;;
 2)
   packages=("bob.blitz")
   ;;
 3)
   packages=("bob.core" "bob.ip.draw")
   ;;
 4)
   packages=("bob.io.base" "bob.sp" "bob.math")
   ;;
 5)
   packages=("bob.ap" "bob.measure" "bob.db.base" "bob.io.image" "bob.io.video" "bob.io.matlab" "bob.ip.base" "bob.ip.color" "bob.ip.gabor" "bob.learn.activation" "bob.learn.libsvm" "bob.learn.boosting")
   ;;
 6)
   packages=("bob.io.audio" "bob.learn.linear" "bob.learn.mlp" "bob.db.wine" "bob.db.mnist" "bob.db.atnt" "bob.ip.flandmark" "bob.ip.facedetect" "bob.ip.optflow.hornschunck" "bob.ip.optflow.liu")
   ;;
 7)
   packages=("bob.learn.em" "bob.db.iris")
   ;;
esac
}

for layer in `seq 1 7`;
do
 get_layer ${layer}
 for pkg in "${packages[@]}";
 do
   pip install $pkg
 done
done

为了加快上一个脚本中的编译速度,您可以在并行线程中进行编译。只需设置一个环境变量BOB_BUILD_PARALLEL=N,其中N是您计算机上最大并行进程数。

答案 1 :(得分:1)

出于某种原因,我不允许对@ 183.amir的帖子发表评论,但这应该作为对How to install Bob from source without conda的评论。为了加速183.amir的最终脚本中的编译,您可以在并行线程中进行编译。只需设置一个环境变量BOB_BUILD_PARALLEL=N,其中N是您计算机上最大并行进程数。