Install wxPython in buildout

While completing setup of this blog with WordPress, I’ve also been working on another task: adding wxPython dependency to a pythonic project of mine. The deployment of this project is done through buildout, a nice piece of software that handles a sandboxed environment for python projects.

You can find download and install instructions to start a buildout barebone here, however I will do a small recap:

First, check that your python installation has setuptools installed (platform-specific install instructions here).

Then run the following commands to create your new project and fetch bootstrapping script:

$ mkdir projectdir
$ cd projectdir
$ wget*checkout*/zc.buildout/trunk/bootstrap/
$ mkdir downloads # this is needed, as buildout won't create it by itself.

Next step is writing buildout.cfg, an ini-style configuration file that specifies the setup for your deployment. The generic section is named “buildout” and its “parts” attribute refers to other sections that must be evaluated. I’ve created two parts: an example named “myproject”, which downloads, builds and installs a couple of fake eggs with wxPython in PYTHONPATH and a “wxPython” part, which downloads, builds and installs wxPython inside “parts” directory.

Each part is evaluated using a recipe, which is a plugin that is dynamically download from eggs repository or any other repository you pass through a find-links attribute. For my purposes I’ve employed two recipes from minitage project, a software deployment project developed by a nice french dude called kiorky (you can chat with him and obtain support at #minitage on

download-cache = downloads
parts =

recipe = minitage.recipe.egg
eggs =
extra_paths = ${wxPython:location}/lib/python

recipe = minitage.recipe.cmmi
url =
post-make-hook = ${buildout:directory}/
configure-options =
    --enable-debug --enable-debug_gdb # replace with --enable-optimize in production code
# Platform-dependent options, add as needed. Platform names are from sys.platform.lower().
configure-options-darwin = --with-mac --enable-monolithic
configure-options-linux2 = --with-gtk2

Configure-make-make-install recipe, namely minitage.recipe.cmmi, has a series of special options called “hooks” that allow extending the building process with non-standard actions through python code. I’ve added a call to wxpython_post_make_hook in to deal with special post-install code:

import os
import sys
import subprocess

def wxpython_post_make_hook(o, b):
    return[sys.executable, '',
        'WX_CONFIG=%s' % os.path.join(o['location'], 'bin', 'wx-config'),
        'BUILD_GIZMOS=0', 'BUILD_STC=0',
        'install', '--home=%s' % o['location'],
        ], cwd=os.path.join(o['compile-directory'], 'wxPython'))

Please note that I’ve disabled gizmos and stc support from wxPython, because I don’t need them and ¬†they would require additional building in contrib.

Finally, launch the bootstrapping code:

$ python2.6 ./

Of course, if you have a different version of python installed, adjust the command accordingly.

Now buildout is ready to be executed with:

$ ./bin/buildout

That’s all folks!

This entry was posted in Coding, How-tos and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>