Although PyV8 has a wiki page entitled How To Build it’s not simple to get the project built. They recommend using prebuilt packages, but there are none for recent version of Ubuntu. In this post I’ll describe how to build it on Ubuntu 11.11 and give a simple example of it in action.
The first step is make sure you have the appropriate packages. There may be others that are required and not part of the default install, but there are what I had to install.
sudo aptitude install scons libboost-python-dev
Next you need to checkout both the V8 and PyV8 projects using the commands below.
svn checkout http://v8.googlecode.com/svn/trunk/ v8 svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8
The key step before building PyV8 is to set the V8_HOME environment variable to the directory where you checked out the V8 code. This allows PyV8 to patch V8 and build it as a static library rather than the default dynamic library. Once you’ve set that you can use the standard Python setup.py commands to build and install the library.
cd v8 export PyV8=`pwd` cd ../pyv8 python setup.py build sudo python setup.py install
>>> import PyV8 >>> ctxt = PyV8.JSContext()