Experimental Minefield PyXPCOM development packageĀ 

Heads up: this package is largely out of date. Check out Mark Hammond's script, and the pyxpcomext project.

This is a self-contained package which includes the code from extensions/python/xpcom and extensions/python/dom. It is packaged as an installable bundle (add-on), which makes it easy to get started with coding in Python on the Mozilla platform.


  • Minefield (built against Gran Paradiso alpha8, other builds may not work)
  • Python matching the version the extension was built with:
    • 2.5.1 on Linux (stock Ubuntu Feisty package)
    • 2.5 on win32 (the one from MozillaBuild)
  • A Linux or win32 platform


Install pyxpcom-0.1.20071009.xpi. You should then find a PyXPCOM entry on your Tools menu, containing about:python, the pyxultest suite, and a small Python console I've written.


Getting PyXPCOM to work from an extension requires jumping through several hoops.

First, the module search path needs to be adjusted, so that the required modules can be loaded from the extension directory. This was straightforward, following the example that adds $bindir/python.

Second, (and its equivalent on other platforms) is required by all Python code (the module loader, the _xpcom module, etc). Normally, you adjust the library search path (for example, via LD_LIBRARY_PATH) and the world is happiness and glee. However, I haven't found out a good way of doing that from an extension, if it is at all possible. Instead, registers itself as a component observing xpcom-startup, and thus is already loaded at the time the other modules need it. This is quite a hack, but it works. Notably, it forces loading the library even if nobody needs it.

You can download my patch for the above here. It also includes fixes for bug 368476 and bug 355608 which were not resolved at the time of writing.