[Python-Dev] python/dist/src setup.py,1.52,1.53

Greg Ward gward@python.net
Wed, 5 Sep 2001 22:53:11 -0400


On 05 September 2001, Martin von Loewis said:
> Even if it works, we may find that this approach causes the module not
> to be build on systems which would support it. The problem is that
> curses.h may include other header files which contain the definition
> we are looking for. The only real test is the one that autoconf uses,
> i.e. AC_TRY_COMPILE. Supporting that in distutils is probably
> something that needs careful planning.

The distutils "config" command was precisely that: a start at
reimplementing Autoconf in Python.  I didn't get very far, but I got far
enough to convince myself that it's very much worth doing.  For example,
here's my analog to AC_TRY_COMPILE, the try_compile() method of the
distutils.command.config.config class:

    def try_compile (self, body, headers=None, include_dirs=None, lang="c"):
        """Try to compile a source file built from 'body' and 'headers'.
        Return true on success, false otherwise.
        """
        from distutils.ccompiler import CompileError
        self._check_compiler()
        try:
            self._compile(body, headers, lang)
            ok = 1
        except CompileError:
            ok = 0

        self.announce(ok and "success!" or "failure.")
        self._clean()
        return ok

I'd much rather write Autoconf (and Autoconf scripts) in Python than in
Bourne shell!

I ran out of steam on the "config" command about the same time I ran out
of steam on the Distutils in general, ie. right around when Python 2.0
was released.  Sigh.  The idea is sound, the implementation is started,
it just needs to be carried through.

The main problem when I left off is what to do with config info between
runs of the setup script; if it's treated just like any other Distutils
command, you'd end up doing the equivalent of re-running "configure"
every time your run "make", which would be mind-blowingly bogus.  I
suspect the answer is to drop a pickle of the configuration state
somewhere.

There's also a lot of grunt-work coding required to implement a usable
subset of Autoconf.

        Greg
-- 
Greg Ward - Unix weenie                                 gward@python.net
http://starship.python.net/~gward/
Jesus Saves -- but Moses gets the rebound, he shoots, he SCORES!