[Distutils] Question re extension modules.

Titus Brown titus at caltech.edu
Fri Jan 14 20:15:21 CET 2005

Hi again,

I'm developing a C++ library & associated extension module within the
same directory.  My setup.py contains this line:

parser_mod = Extension("paircomp._paircomp_parser",
                       libraries=['paircomp', 'stdc++'])

One of the important libraries that I need to include is -lpaircomp,
in '../lib/libpaircomp.a'.

Currently when I change libpaircomp.a (by, for example, making some
internal change to the C++ library that's not reflected in the API)
my Python extensions do not get recompiled by 'python setup.py build'.
(This is run automatically by the Makefile.)

So at the moment I either have to use Makefile trickery or just do an
'rm -fr build' to force recompilation of the extension when the library
is changed.

Is there a canonical way to tell distutils that 'this extension depends
on this file, so force rebuild if the file changes'?

One obvious possibility would be to simple compare last-changed dates
on all of the libraries with last-changed dates on the .so file
produced by setup.py.


More information about the Distutils-SIG mailing list