Skip to: site menu | section menu | main content

IronPython in Action News

News on the IronPython in Action book and sources.

Currently viewing: Front Page

Entries in the Category “sources”

IronPython in Action Examples on Mono

written by Michael Foord, on 6/9/09 11:45 AM.

Chapters three to six of IronPython in Action take you through building a simple example application called MultiDoc. MultiDoc is a multi-tabbed text editor using Windows Forms for the user interface. It is built with a few common design patterns (Model View Controller, command pattern, observer pattern and so on) to demonstrate structured programming with Python. In the process of building MultiDoc the reader will work with various .NET libraries and explore Python language features.

The source code for all the examples in the book can be downloaded from the Manning website or from the Sources page of this website.

The MultiDoc text editor

The intention is that MultiDoc, along with as many examples from the book as possible, run on both Mono and the .NET framework; IronPython isn't just for Windows but can also be used on Linux and Mac OS X or anywhere that Mono will run.

Some readers have reported that MultiDoc crashes on exit when run with Mono. The root cause of this is the old version of IronPython 2 that ships with Mono. The full Mono distribution includes both IronPython 1 and 2, so after installing the full version of Mono you can run commands like:

ipy MultiDoc.py
ipy2 MultiDoc.py

Note

In the debian and Ubuntu distributions of Linux IronPython is packaged separately from Mono. You can install IronPython 1 with: sudo apt-get install ironpython.

The versions of IronPython included in Mono come from the FePy project; a community distribution of IronPython which can be compiled with Mono. The version of IronPython 2 is 2.0 Alpha 5 which is pretty old. Unfortunately Mono bugs or incompatibilities have stopped more recent versions being compiled with Mono. It isn't all bad news as IronPython 2.6 can be compiled with Mono which means we should have a FePy updated once this comes out. You can read more on the details in the FePy Status Update.

Some bug in either IronPython or Mono means that you will see the following crash on exiting MultiDoc when using IronPython 2a5 from Mono:

**
ERROR:generic-sharing.c:301:move_subclasses_not_in_image_foreach_func:
    assertion failed: (subclass->image == image)
Abort trap

This is reason enough to look at using a more recent version of IronPython 2. Even though IronPython can't be compiled with Mono you can still use the up to date Windows binaries (which is part of the point of Mono - binary compatibility). To use the latest version of IronPython (2.0.1) you'll need Mono 2.4 or more recent. For Mac OS X you can use the Mono Apple installer. For Linux you'll need to build Mono from source. This blog entry by Ali Afashar explains how to get IronPython 2 working with Ubuntu:

Back to top