[Distutils] generating pyc and pyo files

Greg Ward gward@cnri.reston.va.us
Tue, 30 Mar 1999 08:18:54 -0500


Quoth Andrew Dalke, on 29 March 1999:
> Michael P. Reilly <arcege@shore.net> said:
> > I disagree.  I see no reason to double the size of the
> > distribution by shipping redundent files (on average, a .pyc
> > is 78.786% of a .py, based on the Python 1.5.1 distribution;
> > .pyo is 88.148%).
> 
> I believe you misread the intention.  Only the .py files
> will be shipped.  Once downloaded they are unpacked into the
> "build" directory.  The .pyo and .pyc files are generated
> in the build directory on the local (downloaded) machine.
> Once these files are compiled locally, they are installed into
> the install directory.

Well, actually, you're both right.  Compiling .py files at build time
will not affect *source* distributions, which is what Andrew is talking
about.  But it *will* affect the size of *built* distributions, which is
what Michael is talking about (I assume).  The whole reason I've been
calling them "built distributions" instead of "binary distributions" is
because of the presumed inclusion of .pyc/.pyo files.

I'll have to play around a bit to see how much including .pyc's in the
built distributions affects the final size of the .tar.gz or .zip (or
.rpm, or whatever) file.  Let's see, tarring and zipping up the current
Distutils 'build' directory with .pyc files looks like this:

-rw-r--r--   1 gward    staff      41363 Mar 30 08:12 distutils-bdist-1.tar.gz
-rw-r--r--   1 gward    staff      51629 Mar 30 08:13 distutils-bdist-1.zip

and if I delete the .pyc's and try again:

-rw-r--r--   1 gward    staff      20544 Mar 30 08:13 distutils-bdist-2.tar.gz
-rw-r--r--   1 gward    staff      25447 Mar 30 08:13 distutils-bdist-2.zip

So!  Michael was almost exactly right, including the .pyc's really does
double the size of the built distribution.  .pyc files compress roughly
as well as .py files.

Does this seem like a problem to anyone else?  I still want to keep
installation as simple as possible -- and, more importantly, be able to
trivially determine the set of files that will be installed -- but if
increasing the size of built distributions really bothers you, speak up!

        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