Sunday, April 13, 2008

Fixing lilypond-book 2.11.43

Upgrading from LilyPond 2.11.41 to 2.11.43 this morning broke lilypond-book. The problem seems to be due to a python versioning problem. A special import statement makes an easy fix. Details follow.

lilypond-book is a python script with the shell directive #!/usr/bin/python as the first line. No problem unless /usr/bin/python points to a version of python older than 2.4. This is, on my system, in fact the case.

$ /usr/bin/python -V
Python 2.3.5

Why is this is a problem? Because the python set( ) constructor didn't become a language built-in until version 2.4 or so. Prior to that, you had to invoke set( ) with something like sets.Set( ) after importing the sets module somewhere.

On my box I have python 2.5 installed and set as to run as the default python in my path.

$ which python
/Library/Frameworks/Python.framework/Versions/Current/bin/python

$ `which python` --version
Python 2.5

So I have two options.

  1. Fix lilypond-book to look at the python 2.5 install on my user path
  2. Stick an import statement somewhere at the top of lilypond-book so python 2.3.5 can reference sets.Set( ) globally as set( )

I don't know enough lilypond-book for option #1 so I went the option #2 route instead and stuck from sets import Set as set at line 37. And now lilypond-book 2.11.43 is happy.

There's a bug-lilypond thread open on lilypond-book 2.11.43 troubles. Graham started the thread, Han-Wen replied, and maybe these notes will help find the fix.



No comments: