By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

building arbitrary files with distutils?

P: n/a
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.wilbertberendsen.nl/
"You must be the change you wish to see in the world."
-- Mahatma Gandi
Mar 10 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Mar 10 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.