Using the pipeline module ruffus with Python 3.2

The Python module ruffus is a great companion for setting up pipelines easily and quickly. Unfortunately the development has been focused on Python 2.x … until recently. There are some recent adaptations to get it running under Python 3.x but there are some modifications needed.

At first download the development version of ruffus:

$ svn checkout ruffus-read-only

Then use the 2to3 tool to for the code conversion:

$ 2to3 -w ruffus-read-only/

Let’s check if this works by running a small script:

$ cd ruffus-read-only/
$ emacs -nw
$ cat
from ruffus import *

def first_task():

def second_task():

$ python --version
Python 3.2
$ python
Traceback (most recent call last):
  File "", line 10, in 
  File "[...]/ruffus-read-only/ruffus/", line 2675, in
    pool_func = imap
NameError: global name 'imap' is not defined

As you can see 2to3 did not do the full job. But the code needs only a small adaptation to be Python 3.x compatible (it is a tiny problem due to changes in itertools):

$ cp ruffus/ ruffus/
$ emacs -nw ruffus/
$ diff ruffus/ ruffus/
<         pool_func = imap
>         pool_func = map

$ python
    Job completed
Completed Task = first_task
    Job completed
Completed Task = second_task 

Now it works!