This page explains how to install and run Pyjamas and Pyjamas Desktop with WebKitGTK on Ubuntu.
<pre>$ git clone https://github.com/pyjs/pyjs.git</pre>
This should create a directory `pyjamas/` containing the current development source code.
Run bootstrap.py to create the 'bin/' directory, containing wrapper programs necessary to compile Pyjamas applications, and also to create the file 'pyjd/__init__.py' for pyjamas-desktop integration. <pre> $ cd pyjamas pyjamas$ python bootstrap.py </pre>
It is useful to add the 'bin/' directory to your `PATH` variable (and/or to ~/.bashrc), for example:
<pre> pyjamas$ export PATH=`pwd`/bin:$PATH </pre>
A first test can be done now:
<pre> pyjamas$ cd examples/helloworld/ pyjamas/examples/helloworld$ python . </pre>
This generates a directory `public/` containing `Hello.html` and a lot of other files and directories.
Now you can open 'public/Hello.html' in firefox:
<pre> pyjamas/examples/helloworld$ firefox public/Hello.html </pre>
Now go back to the `pyjamas/` root directory for the next step.
<pre> pyjamas/examples/helloworld$ cd ../.. </pre>
NOTE: pythonwebkit doesn't support Canvas applications. If you intend to run an app that uses Canvas, instead try xulrunner (only tested on 9.10).
See also: Pyjamas Desktop on Ubuntu with WebKit
(From suzan on the mailing list)
<pre> git clone --depth 1 git://git.savannah.gnu.org/pythonwebkit.git cd pythonwebkit git checkout python_codegen cd ..
sudo apt-get install python-dev python-ply
.# note: you only need this if your distro has libsoup version less than 2.29.90 .# most linux distros now have at least libsoup 2.4, now. so if you can .# do e.g. "apt-get install libsoup2.4-dev" instead, you can skip ahead... git clone git://git.gnome.org/libsoup cd libsoup git checkout LIBSOUP_2_29_90
apt-get install the following before running autogen.sh in libsoup: gnome-common gtk-doc-tools python-gtk2-dev libxml2-dev
./autogen.sh --without-gnome ./configure --without-gnome make sudo make install cd ..
(If you have problems when building libsoup with header files such as glib.h not being found, it may be that setting PKG_CONFIG_PATH to an appropriate value helps: for example I found I had to set it to /usr/local/lib/pkgconfig/:/usr/lib/pkgconfig/:/usr/share/pkgconfig before this would work.)
.#... to here. to reiterate: this is the point where you can skip ahead .# if you can do "apt-get install libsoup2.4-dev" or other version of .# libsoup which is clearly greater than 2.29.90.
sudo apt-get install build-essential sudo apt-get build-dep libwebkit-1.0-2 sudo apt-get install libwebkit-1.0-2 sudo apt-get remove libwebkit-1.0-2
cd pythonwebkit mkdir build cd build ../autogen.sh ../configure make sudo make install cd ../..
.# quick sanity check that python can import pywebkitgkt python >>> import pywebkitgtk >>> .# if there is a problem here it may be helpful to check /etc/ld.so.conf to ensure .# it contains /usr/local/lib, and also to run ldconfig -p to double-check t .# hat the python webkit library is listed. .# also consider doing "ldd /usr/local/lib/libwebkitgtk-python-1.0.so.0" .# and double-check that the library can find all its runtime libs.
</pre> Create the 'pyjdrc' file <pre> mkdir ~/.pyjd vi ~/.pyjd/pyjdrc </pre> Save the following 2 lines in ~/.pyjd/pyjdrc <pre> [gui] engine:pywebkitgtk </pre>
In pyjamas dir: <pre> python run_bootstrap_first_then_setup.py build sudo python run_bootstrap_first_then_setup.py install
</pre> Finally, test the Mail application using Pyjamas Desktop <pre> cd examples/mail python Mail.py </pre>
Now you can in principle run pyjamas applications the normal way, but it will fail:
<pre> pyjamas/examples/helloworld$ python Hello.py Traceback (most recent call last): File "Hello.py", line 1, in <module> import pyjd # this is dummy in pyjs. File "/home/marcus/projects/pyjamas/pyjamas/pyjd/__init__.py", line 36, in <module> from hula import * File "/home/marcus/projects/pyjamas/pyjamas/pyjd/hula.py", line 22, in <module> import hulahop ImportError: No module named hulahop </pre>
So, to make this work, you need to install the necessary prerquisites.
The following should work, but doesn't in current Ubuntu (2009-11-08) <pre> $ sudo apt-get install python-hulahop </pre>
You probably still get an error:
<pre> pyjamas/examples/helloworld$ python Hello.py Traceback (most recent call last): File "Hello.py", line 1, in <module> import pyjd # this is dummy in pyjs. File "/home/marcus/projects/pyjamas/pyjamas/pyjd/__init__.py", line 36, in <module> from hula import * File "/home/marcus/projects/pyjamas/pyjamas/pyjd/hula.py", line 22, in <module> import hulahop File "/usr/lib/python2.6/dist-packages/hulahop/__init__.py", line 29, in <module> from hulahop._hulahop import shutdown ImportError: libxul.so: cannot open shared object file: No such file or directory </pre>
Unfortunately, the Ubuntu package of python-hulahop is a failure, so you need to rebuild it instead (you need to repeat this whenever you update your browser).
<pre> $ mkdir /build-hulahop $ cd /build-hulahop $ sudo apt-get build-dep hulahop $ sudo apt-get -b source hulahop $ sudo dpkg -i python-hulahop_0.4.9-1ubuntu2_amd64.deb </pre>
But it still fails:
<pre> $ python Hello.py Traceback (most recent call last): File "Hello.py", line 1, in <module> import pyjd # this is dummy in pyjs. File "/home/marcus/projects/pyjamas/pyjamas/pyjd/__init__.py", line 36, in <module> from hula import * File "/home/marcus/projects/pyjamas/pyjamas/pyjd/hula.py", line 26, in <module> hulahop.startup(gecko_path) File "/usr/lib/python2.6/dist-packages/hulahop/__init__.py", line 56, in startup from xpcom import components ImportError: No module named xpcom </pre>
Ubuntu dropped the ball on this one. Due to a bug in epiphany, Ubuntu removed even the option to install and use python-xpcom (really lame, no style points for this one, Buh!).
You can try the xpcom build from the <a href="http://pyjamas-dev.googlegroups.com/web/xpcom-ubuntu-9.10.tar.gz">xpcom-ubuntu-9.10.tar.gz</a> package.
Alternatively, you have to build it yourself. Unfortunately this means building xulrunner, which takes a lot of time and disk space (3 GB!). Here is a quick way to utilize a quad-core processor in the build process:
<pre> $ apt-get source xulrunner-1.9.1 $ cd xulrunner-1.9.1-18.104.22.168+nobinonly/ $ sudo apt-get build-dep xulrunner-1.9.1 $ dpkg-buildpackage -rfakeroot -b -uc -j4 </pre>
The `4` in the `-j4` specifies the number of processors to use. This command builds a couple of packages, but we don't need them, they are identical to the ones in the Ubuntu archive. What we want is in the build tree that is left behind. You can install the xpcom package anywhere where python can find it. If you set the `$PYTHONPATH` as above, the following installs it inside the pyjamas directory:
<pre>$ cp -rL debian/tmp/usr/lib/xulrunner-22.214.171.124/python/xpcom $PYTHONPATH</pre>
That's it! Now the `python Hello.py` command from above should work.
Many people do not run "python bootstrap.py" followed by "python run_bootstrap_then_setup.py install". This results in the errors and workarounds, below. It is a complete pain to run these workarounds, so it is best to actually do a system-wide install. There are however limitations of doing a system-wide install in this way (especially if doing development on pyjamas itself, or the installation is intended for multiple users) so below is actually a good workaround for doing "isolated sandbox" installs, that do not require root access and will also have no impact on any other users.
To run pyjamas-desktop, we have to set the python path to the pyjamas library, so pyjd can find it: <pre>pyjamas$ export PYTHONPATH=`pwd`</pre>
Otherwise you get an error: <pre> pyjamas/examples/helloworld$ python Hello.py Traceback (most recent call last): File "Hello.py", line 1, in <module> import pyjd # this is dummy in pyjs. ImportError: No module named pyjd </pre>
Other examples use the UI libraries. For these, you also need to add the `library/` directory in the pyjamas directory to `PYTHONPATH`.
Ha, it could be as simple as <pre>$ sudo apt-get install libboost-python1.38-dev</pre>
But if you followed the above you know what's coming. If you build V8 and PyV8 eventually this breaks with: <pre> AttributeError: 'Boost.Python.StaticProperty' object attribute '__doc__' is read-only </pre>
<p><a href="https://bugs.launchpad.net/ubuntu/+source/boost1.38/+bug/457688">Bug details</a></p>
So instead we need to use a fixed boost package. Instead of building your own (even 1.40 is not good enough), just install it from ajmitch's PPA repository. <pre>https://launchpad.net/~ajmitch/+archive/ppa</pre>
For this, add this to apt sources.list:
And then do a apt-get update/upgrade cycle (make sure libboost-python1.38-dev is installed).
"Instructions" (haha) are hidden at: <pre>http://code.google.com/p/v8/wiki/Source?tm=4</pre>
But don't bother, it's not this simple. G++ 4.4 (the Ubuntu) default doesn't work, the latest SVN repository of V8 is too new for current PyV8, you need special flags for x64 architecture and so on and so forth. Just do this (for x64, for another architecture you are on your own):
<pre> $ mkdir v8 $ cd v8 v8$ svn checkout http://v8.googlecode.com/svn/trunk/ -r 3167 v8 v8$ cd v8 v8/v8$ CC=gcc-4.3 CXX=g++-4.3 CCFLAGS=-fPIC scons arch=x64 v8/v8$ export V8_HOME=`pwd` v8/v8$ cd .. </pre>
<pre> v8$ svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8 v8$ cd pyv8 v8/pyv8$ CXX=g++-4.3 CC=gcc-4.3 python setup.py build v8/pyv8$ CXX=g++-4.3 CC=gcc-4.3 python setup.py install --prefix `pwd`/../pyv8-install v8/pyv8$ cd .. v8$ PYTHONPATH=$PYTHONPATH:`pwd`/pyv8-install/lib/python2.6/site-packages </pre>
Based on information at: <a href="http://code.google.com/p/pyv8/wiki/HowToBuild">http://code.google.com/p/pyv8/wiki/HowToBuild</a>
In `pyjamas/examples/libtest`, follow the README.
<p>For me, this fails, with various issues, but none related to actually finding PyV8.</p>
<p>By now you have lost your hair, your humour, and probably your interest. In a couple of month though all these problems will be replaced by new ones! Have fun.</p>
Last edited by bittner,