Sep 11, 2013

Boost.python for virtualenv (FINALLY!)

After hours of struggling, I did succeed to build boost for multiple pythons on virtualenv environments.
Boost Web Site helped me very much.
 As a conditions, you should know python 2.7.3 and 3.2 were installed by pythonz + virtualenv beforehand. I installed boost.python as follows.

1. Download boost from here.

2. unzip archive.
> tar -xvfz boost_1_XX_X.tar.bz2

3. Exec bootstrap.sh
> cd boost_1_XX_X
> ./bootstrap.sh

 4. Edit project-config.jam as follows
# Boost.Build Configuration
# Automatically generated by bootstrap.sh

import option ;
import feature ;

# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! darwin in [ feature.values  ]
{
    using darwin ; 
}

project : default-build darwin ;

# Python configuration
using python : 2.7 : /PATH/TO/VIRTUALENV/PYTHON2.7
  : /PATH/TO/VIRTUALENV/PYTHON2.7/HEADERS #includes
  : /PATH/TO/VIRTUALENV/PYTHON2.7/LIBS #libraries
  ;
using python : 3.2 : /PATH/TO/VIRTUALENV/PYTHON3.2
  : /PATH/TO/VIRTUALENV/PYTHON3.2/HEADERS #includes
  : /PATH/TO/VIRTUALENV/PYTHON3.2/LIBS #libraries
  ;

# List of --with- and --without-
# options. If left empty, all libraries will be built.
# Options specified on the command line completely
# override this variable.
libraries = --with-python ;

# These settings are equivivalent to corresponding command-line
# options.
option.set prefix : /Users/MYSELF/local ;
option.set exec-prefix : /Users/MYSELF/local ;
option.set libdir : /Users/MYSELF/local/lib ;
option.set includedir : /Users/MYSELF/local/include ;

# Stop on first error
option.set keep-going : false ;
5. run b2
> ./b2 install

If everything goes right, you can find new headers and libs in MYSELF/local/include and MYSELF/local/lib.

No comments: