4

Bob recommends its users to install its packages using conda, but I do not want to use conda. How can I install it from source?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
183.amir
  • 422
  • 3
  • 25

2 Answers2

5

Explanation

First of all, using conda to Install Bob is much easier and is the supported way to install Bob. Please consider again to use conda to install Bob before continuing. Bob is written in a mix of C++ and Python and links to a lot of different C/C++ libraries and Conda is a language-agnostic binary package manager which would handle all these.

If you want to install Bob from source, you first need to install its dependencies manually. The dependencies for each package is listed inside the conda recipe of each Bob package. From its conda recipe, you have to install (if they exist) requirements:build, requirements:host, requirements:run, and test:requires. These packages are conda packages and not pip packages; some of them could be pip packages (the names could be different) and some of them could be just a C/C++ library that you should install with your system's package manager (or from source).

For example, bob.extension's conda recipe is 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

Parsing this recipe would mean that you would need to install: boost, cmake, pkg-config, freetype, libblitz, C and C++ compilers, and probably numpy with your system's package manager first and then install click, click-plugins, nose, coverage, sphinx, sphinx_rtd_theme, and bob.buildout with pip. (You can also look into requirements.txt and test-requirements.txt of Bob packages for the pip package names of dependencies but that may not be updated to match its conda recipe). bob-devel is a conda meta-package which you do not need to install when not using conda.

This will setup your environment to be ready to compile (if needed), install, and test bob.extension. After setting up the environment, you can use pip to install bob.extension:

pip install bob.extension

Then, you would need to go about installing the next Bob package in order of Bob packages dependencies. As you can see, this can be quite time-consuming but this is the only way to do it that will work as Bob's packages are developed and their dependencies are changed.

Instructions

These instructions will help you install most of Bob packages that contain C++ code which are harder to install. After you have installed these packages, you most probably can install the rest of Bob packages using pip.

Dependencies

You need to install Bob packages dependencies first using your system's package manager.

+-------------+------+-------------------------+---------------------+
| 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/> |      |                         |                     |
| `__         |      |                         |                     |
+-------------+------+-------------------------+---------------------+

Once the dependencies are installed you can use pip to install from source.

It is possible to install packages using pip, globally or on your private virtualenv, if that is the way you like your Python work environments. You will need to manually install all packages you need (directly or indirectly), as pip/setuptools has presently no way to coherently install Python packages that depend on each other for building, such as is the case of many packages.

For example, to install bob.io.image in a newly created virtual environment, here is the sequence of commands to execute:

$ 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

Each pip command must be executed separately, respecting the inter-package dependency.

The following will not work as expected:

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

The dependency of core packages can be summarized into 7 layers and the following script can be used to install all core packages using 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

To speed up the compilation in the last script, you can compile in parallel threads. Just set an environmental variable BOB_BUILD_PARALLEL=N where N is the maximum number of parallel processes on your machine.

183.amir
  • 422
  • 3
  • 25
1

For some reason, I am not allowed to comment on @183.amir's post, but this should be taken as a comment to How to install Bob from source without conda. To speed up the compilation in 183.amir's final script, you can compile in parallel threads. Just set an environmental variable BOB_BUILD_PARALLEL=N where N is the maximum number of parallel processes on your machine.

Siebenkopf
  • 13
  • 2