Patch: Building TkAgg backend without a running X server

Hi,

I've reworked the Tcl/Tk checking code in setupext.py (see attached
patch). It is now possible to build matplotlib with Tk support without
requiring a running X server. This is useful for doing autobuilds
(e.g. as done by Debian) and for building a package on one machine to
be installed and used on another.

This seems to be an old issue... (see matplotlib-devel, "building
matplotlib without X-server connection," 11 Nov 2004)

The patch also fixes a potential hang, which happens when I try to
build the latest matplotlib on Debian Etch with Python 2.4, on a
system with libtk8.4-dev installed but no running X server. The build
should have continued without TkAgg support, but it hangs. The hang
occurs because the Tcl/Tk checking code calls Tkinter.Tk() multiple
times, which is not a good idea. In fact, just running the following
snippet hangs the interpreter in this scenario:

import Tkinter
tk = Tkinter.Tk()
tk = Tkinter.Tk()

The patch applies to setupext.py in revision r3975. I checked it with
matplotlib r4064, using Python 2.4 on Debian Etch, and Python 2.5 on
Mac OS X 10.4.10. Could someone please check it with Python 2.3 and on
Windows?

Regards,
Ludwig

setupext.py.patch (10.9 KB)