[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

building arbitrary files with distutils?

Wilbert Berendsen

3/10/2008 8:27:00 PM

Hi all,

I want to convert a python project from Makefiles to distutils. Currently the
makefiles perform some tasks like building a PNG icon from a SVN file etc.

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....

w best regards,
Wilbert Berendsen

--
http://www.wilbertber...
"You must be the change you wish to see in the world."
-- Mahatma Gandi
1 Answer

Martin v. Loewis

3/10/2008 10:14:00 PM

0

> 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