Python: Build PyV8 for Python3 on Ubuntu

PyV8 is a Python wrapper for Googles V8 Javascript Engine. Initially it was only possible to use it in combination with Python 2. But since February 2013 it is possible to use it with Python 3. In this article I will show how to build the wrapper on Ubuntu 12.04. But it should also be possible to apply this steps on other distributions.

Before starting to build the Javascript Engine all the required packages have to be installed.

$ sudo apt-get install subversion build-essential libboost-python-dev python3.2-dev libboost-system-dev libboost-thread-dev

At the moment it's a good idea to fetch the latest source code from the repository to build the V8 library and the wrapper.

$ cd ~
$ mkdir svn
$ cd svn
$ svn checkout v8
$ svn checkout pyv8-read-only

Before starting to build the wrapper some dependencies for the V8 library have to be installed.

$ cd v8
$ make dependencies
$ cd ..

If the installation was successful it's time to start building the wrapper itself. First of all the has to be modified. Line 129 has to be changed accordingly to the following example.

boost_libs = ['boost_python-py32', 'boost_thread', 'boost_system']

Now it's time to build and install the PyV8 wrapper.

$ cd pyv8-read-only/
$ V8_HOME=$HOME/svn/v8/ python3.2 build
$ sudo python3.2 install

In some situations it might be a good idea to install the wrapper inside a virtual python environment. Due to some dependency problems only the last command should be run inside the environment. In this case the 'sudo' command can be left out.

Verwandte Artikel