py2exe and library.zip

Peter Hansen peter at engcorp.com
Wed May 4 07:25:46 EDT 2005


Timothy Smith wrote:
> Peter Hansen wrote:
>> Anything's possible.  Maybe you could explain what you're actually 
>> trying to accomplish (or the reasons) so we can better understand 
>> where you're going with this...
>>
> exactly what i just stated, i don't want py2exe to zip up it's 
> library's, but to put them in a sub dir.
> the reason for this, is so that when users login and update from svn, 
> they only have to download some tiny pyc files, not a great big zip file 
> with everything in it ( 99% of which never changes)

More detail on this version control thing would probably help.  (Things 
like that are why I asked fo more background... "exactly what I stated" 
isn't as useful as something like (for example) "I want my app users to 
use Subversion to retrieve updates to the application without having to 
download a big zip file".)

Do you know that Subversion has (as I understand it) a fairly 
intelligent binary file comparison routine, and it will (again, as I 
understand it) not transmit the entire contents of the zip file but 
would actually send only the portions that have changed?  At least, 
that's if the file isn't compressed in some way that prevents this 
algorithm from working well.  (Note to self: check if zip files that can 
be in sys.path can be compressed, and if py2exe compresses them.)

Anyway, while this sort of thing isn't directly supported (probably 
since almost nobody would want to do it, for reasons similar to what 
Simon has explained), you should be able to work it out yourself.  The 
.exe produced by py2exe contains a "stub" executable that basically sets 
  sys.path to point to the .zip file, then runs the main .py which has 
been integrated into the .exe file (not even compiled to a .pyc, just 
like normal).  If you modify your main .py to adjust sys.path to point 
to an external subdirectory, you should be able to leave .py files (or 
.pyc files) there and use svn to update them.

I'll leave it as an exercise for the reader (mainly because I don't know 
how to do it offhand) what you should do to prevent py2exe from putting 
all your files in its zip.  It should probably still put the standard 
library modules there, since otherwise you'd have little reason to be 
using py2exe in the first place...

-Peter



More information about the Python-list mailing list