Useful Python compileall module

Douglas Kosovic douglask at itee.uq.edu.au
Tue Oct 5 21:00:11 CDT 2004


Hi,

I brought up a conversation with Eric in today's Asia-Pacific Townhall 
meeting about the base path of compiled Python files which get used in the 
backtrace error messages, he mentioned I should post what I do to this list. 
With the Fedora RPMs, I prefer that the error messages refer to the location 
where the files are installed, rather than where they were built, so I do 
something like:

python -c 'from compileall import *; 
compile_dir("'$RPM_BUILD_ROOT'/usr/lib/python%{pyver}",10,"/usr/lib/python%{pyver}", 
1)'

more info on compileall module can be found here:
  http://www.python.org/doc/2.3/lib/module-compileall.html

Basically, I force a recompile and specify what the base path should be, 
either /usr/lib/python2.2 or /usr/lib/python2.3, depending on the version of 
Fedora used.


Cheers,
Doug




More information about the ag-dev mailing list