building arbitrary files with distutils?

W

Wilbert Berendsen

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
 
M

Martin v. Löwis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top