Snowberry + wxPython 2.8 + Ubuntu 12.04

15 July 2013
The original motive for this was getting Snowberry (the GUI for the Doomsday Engine), but the mechanics of the process involved are pretty generic for anyone wanting to run Python programs that use wxPython features not in the wxPython version that Ubuntu 12.04 ships with. Python software is a bit of a nightmare when it comes to different versions, and I suspect Ubuntu has stuck with wxPython 2.6 to avoid breaking other software, and annoyingly does not present any easy way to have multiple versions side-by-side.

The general approach (which I have used previously) is to do a home directory install of both Python, and then add to it the wxPython libraries. There are alternative methods, but when messing around with Python, using isolated custom-compiled copies of the interpretor means that there are no nasty surprises resulting from stale binary repositories.

Building all the software

I will be assuming a build directory named wxSrc, and that Python 2.7.5 and wxPython 2.8.12.1 have been downloaded into the ~/Downloads/ directory. Far as I am aware wxPython includes the entire wxWidgets distribution, so there's no need to get wxWidgets seperately even if you want to play around with some of the options. The instructions for building wxWidgets/wxPython are based on those given in wxPython-src-2.8.12.1/wxPython/docs/BUILD.html, with changes mainly to reduce the number of environment variables needed when running. Although /home/remy/ is used here, I assume that anyone with the knowledge to understand these instructions will know how to make any necessary changes for their own home directory.

Extract Python & wxPython

mkdir wxSrc tar -tzvf ~/Downloads/Python-2.7.5.tgz tar -xjvf ~/Downloads/wxPython-src-2.8.12.1.tar.bz2

Build Python 2.7.5

cd Python-2.7.5 ./configure --prefix=/home/remy/wxPython2.8 make make install cd ..

Build wxWidgets

There's problems getting wxWidgets to pick up the OpenGL libraries, which I think is down to where the OpenGL libraries are located on 64-bit versions of Ubuntu. To my knowledge this is fault in wxWidgets' configure script, and for now found it easiest to simply disable OpenGL support.

cd wxPython-src-2.8.12.1 mkdir bld cd bld ../configure --prefix=/home/remy/wxPython2.8 --without-opengl \ --with-gtk --with-gnomeprint --enable-debug \ --enable-debug_gdb --enable-geometry --enable-graphics_ctx \ --enable-sound --with-sdl --enable-mediactrl \ --enable-display --enable-monolithic --enable-unicode \ --with-libjpeg=builtin --with-libpng=builtin \ --with-libtiff=builtin --with-zlib=builtin make make -C contrib/src/gizmos make -C contrib/src/stc make install make -C contrib/src/gizmos install make -C contrib/src/stc install cd ../..

I'm not actually tested to see if the gizmos and stc are actually needed, but the wxPython build instructions specifically mentions then, so I assume they are.

Wire up the file paths

export PATH=/home/remy/wxPython2.8/bin:$PATH export LD_LIBRARY_PATH=/home/remy/wxPython2.8/lib

Check that which wx-config and which python give /home/remy/wxPython2.8/bin/wx-config and /home/remy/wxPython2.8/bin/python respectively.

Build & install wxPython

cd wxPython-src-2.8.12.1/wxPython python ./setup.py build_ext --inplace --debug BUILD_GLCANVAS=0 mkdir /home/remy/wxPython2.8/lib/python2.7/wx cp -r wx/* /home/remy/wxPython2.8/lib/python2.7/wx

If you get a compile error soon after running setup.py, it is mostly likely due to a problem of wx-config not being picked up. The last two lines are a manual installation of the wxPython files into the Python library path, which is an alternative to using the PYTHONPATH environment variable.

Testing wxPython

If all is well, you should be able to run the wxPython widgets gallery:

cd demo python demo.py

Note: Demo directory is wxSrc/wxPython-src-2.8.12.1/wxPython/demo

Cleaning up

If all went well, Python/wxWidgets/wxPython are now all installed under ~/wxPython2.8 and the wxSrc directory can now be deleted. To use wxPython, you just need to set your enviornment variables to pick up the correct binaries:

export PATH=/home/remy/wxPython2.8/bin:$PATH export LD_LIBRARY_PATH=/home/remy/wxPython2.8/lib

I suspect it is possible to rig the wxPython build to statically link to wxWidgets so that LD_LIBRARY_PATH is not necessary, but I have yet to investigate it.