Showing posts with label lilypond-book. Show all posts
Showing posts with label lilypond-book. Show all posts

Saturday, April 19, 2008

Externalizing preamble material and using lilypond-book

lilypond-book processes this minimal LaTeX file just fine.

\documentclass[10pt]{article}
\begin{document}
Hello!
\end{document}

But when we externalize the one-line preamble to a separate file, lilypond-book grumbles.

\include{test-preamble}
\begin{document}
Hello!
\end{document}

With the contents of test-preamble.tex as \documentclass[10pt]{article}.

$ lilypond-book --pdf --output=out test.tex
lilypond-book (GNU LilyPond) 2.11.43
Reading test.tex...
Running latex...This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(/tmp/tmpUlfqXl.tex
LaTeX2e <2005/12/01>
Babel ...

\@input{test-preamble.aux}
No file test-preamble.tex.
No file tmpUlfqXl.aux.

! LaTeX Error: The font size command \normalsize is not defined:
there is probably something wrong with the class file.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.5 \begin{document}

textwidth=8191.99998pt
columnsep=0.0pt
(./tmpUlfqXl.aux) )
(see the transcript file for additional information)
No pages of output.
Transcript written on tmpUlfqXl.log.
command failed: latex /tmp/tmpUlfqXl.tex
Child returned 1

So does lilypond-book know how to process LaTeX \includes? Or is this a known limitation for which the workaround is not to externalize when using lilypond-book?

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.