building arbitrary files with distutils?

"Martin v. Löwis" martin at v.loewis.de
Mon Mar 10 18:14:24 EDT 2008


> How can I add such commands (including timestamp checking) to a setup.py file, 
> so that it runs when I call 'python setup.py build' ? I can write python 
> functions to perform those command, and I found timestamp checking functions 
> in distutils.dep_util, but just can't find the way to connect such commands 
> to the build step....

Take a look at the build_ext command. It considers all Extension objects
(in build_extensions), and for each one, it does dependency checking
(in build_extension). It uses the newer_group machinery.

More generally, in the run method of your command, just don't do
anything (except perhaps logging) if you find your outputs are
up-to-date.

Multi-level dependencies aren't quite supported with that approach;
you can either make multiple commands that one has to run in sequence
(or use subcommands), or you put it all in a single run method which
sequentially first tries to generate the intermediate outputs
(doing nothing if they are up-to-date), and then the final outputs
(doing nothing when they are newer than the intermediate ones).

HTH,
Martin



More information about the Python-list mailing list