[Distutils] generating pyc and pyo files

Greg Ward gward@cnri.reston.va.us
Mon, 29 Mar 1999 20:53:13 -0500


Quoth Andrew Dalke, on 28 March 1999:
> When should the .pyc and .pyo files be generated during the
> install process, in the "build" directory or the "install" one?

Sounds like everyone is in favour of compiling at build time: good.
Nobody mentioned my reason for favouring this, which is simple:
installation should consist of nothing more than copying files and
(possibly) changing modes and ownerships.  All files that will be
installed should be generated at build time.  This makes lots of things
easier, notably: installation itself; updating the mythical database of
installed files; and creating "built distributions" such as RPM.

Also, if you check the code, you'll note that I don't use the
'compileall' module, but rather explicitly follow the list of module to
build.  Being able to catch errors didn't occur to me, but it's one good
reason.  (And Andrew's patch probably won't make it into versions 1.4
through 1.5.1, which I would still like to support.)  I think I just did 
it that way because I don't like ceding control over which files are
processed to an external entity.  (You'll note that distutils supplies
it's own 'copy_tree()' function, for basically the same reason.)

Would anyone interested in error handling care to look into what happens
when 'compile' fails?  Doesn't look like I've done anything in
particular to handle it (see distutils/command/build_py.py, towards the
bottom of the 'run()' method) -- I probably blithely assumed that it
would raise an exception like most IO routines do.

Wow, a thread where everybody agrees... we must be on to to something.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913