Python Makefiles... are they possible?

Roy Smith roy at panix.com
Wed Feb 13 08:44:13 EST 2013


In article <511b2a7c$0$11096$c3e8da3 at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> On Tue, 12 Feb 2013 20:06:35 -0500, Roy Smith wrote:
> 
> > One thing we do in our Makefiles is "find . -name '*.pyc' | xargs rm".
> > It avoids all sorts of nasty and hard to track down bugs (consider what
> > happens if you move a .py file from one place in your source tree to
> > another and leave the old .pyc behind).
> 
> 
> How often do you move files around in the source tree?

It has happened enough times to make us look for a solution.  Which 
means "more than once".

> Meanwhile, *every* time you run make, you take a performance hit on 
> every Python module in your project, whether it has moved or not.

The performance hit is minimal.  The hours of tearing out your hair 
trying to figure out why bizarre things are happening is not.

Another solution would be if there was a flag you could give to Python 
to tell it, "Only import a .pyc if the corresponding .py file exists".  
It's already checking to see if the .py is newer, so this wouldn't even 
cost anything.



More information about the Python-list mailing list