473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

py2exe and library.zip

is it possible instead of py2exe putting all library's in a zip file, to
just put them in a sub dir?
Jul 19 '05 #1
11 3365
Timothy Smith wrote:
is it possible instead of py2exe putting all library's in a zip file, to
just put them in a sub dir?


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...

-Peter
Jul 19 '05 #2
Peter Hansen wrote:
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

ideally i'd love to not to have to use py2exe at all, then they can just
update from the stable branch of my svn. the problem with THAT is how to
install python, wx,pysvn,reportlab etc etc on their systems with no
fuss(py2exe convienently packages all dll's together for me). if you
know of a way i can achieve that i'd be your best friend forever.

the whole reason i'm going with the svn updating method is there is no
user interaction required. even getting users to click a single button
to update has proven too much to ask of them :/

the other reason is my particular project gets updated very often, so
you can imagine the combination of users resistant to any kind of
computer use with an environment requiring frequent updating.
i have some other problems to solve before i get to that point, mainly
svn related eg. pysvn whinges because files exist in the working
directory that it wants to update ( with the same name ), only they
aren't under version control.
Jul 19 '05 #3
In article <ma********************@powergate.ca>,
Peter Hansen <pe***@engcorp.com> wrote:
[ ... ] (Note to self: check if zip files that can
be in sys.path can be compressed,
Yes.
and if py2exe compresses them.)


Don't know, but I assume yes.

Just
Jul 19 '05 #4
Timothy Smith <ti*****@open-networks.net> writes:
is it possible instead of py2exe putting all library's in a zip file,
to just put them in a sub dir?


You can subclass the build_exe command (the extending sample shows how
to do this, althoutgh for a different purpose), and copy the files into
a sub dir instead of building an archive. You still have to make sure
that your exe has this directory on sys.path.

Thomas
Jul 19 '05 #5
Just <ju**@xs4all.nl> writes:
In article <ma********************@powergate.ca>,
Peter Hansen <pe***@engcorp.com> wrote:
[ ... ] (Note to self: check if zip files that can
be in sys.path can be compressed,


Yes.
and if py2exe compresses them.)


Don't know, but I assume yes.


There's an option for that, because it slows down the imports.

Thomas
Jul 19 '05 #6
Peter Hansen <pe***@engcorp.com> writes:
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.)


Even if the files were compressed, which has a net result similar to
randomizing the contents and will certainly extend the portion that
appears "changed", the worst that would happen is that subversion
(which does use a binary delta algorithm) would end up downloading the
single file portion of the zip file rather than the smaller change
within the file. It should still be efficient.

But to be honest, for something like the OPs purpose, it's not clear
that an SCM is needed, since all he's trying to accomplish is bring a
remote copy up to date with the central one. For that you could just
publish a location containing the necessary files and have the users
use something like rsync directly (which is just as efficient in terms
of a binary delta) to update their own local version.

Of course, if the Subversion server is already in place so it's a
convenient server, or if more of the user base already has the client
in place, it should work just about as well.

-- David
Jul 19 '05 #7
David Bolen wrote:
Peter Hansen <pe***@engcorp.com> writes:
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.)


Even if the files were compressed, which has a net result similar to
randomizing the contents and will certainly extend the portion that
appears "changed", the worst that would happen is that subversion
(which does use a binary delta algorithm) would end up downloading the
single file portion of the zip file rather than the smaller change
within the file. It should still be efficient.


Good point. When I wrote that I was picturing the form of compression
that a .tar.gz file would have, not what is actually used inside a .zip
file which is -- quite logically now that you point it out -- done on a
file-by-file basis. (Clearly to do otherwise would risk your data and
make changing compressed zips highly inefficient.)

-Peter
Jul 19 '05 #8
David Bolen wrote:
Peter Hansen <pe***@engcorp.com> writes:
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.)


Even if the files were compressed, which has a net result similar to
randomizing the contents and will certainly extend the portion that
appears "changed", the worst that would happen is that subversion
(which does use a binary delta algorithm) would end up downloading the
single file portion of the zip file rather than the smaller change
within the file. It should still be efficient.

But to be honest, for something like the OPs purpose, it's not clear
that an SCM is needed, since all he's trying to accomplish is bring a
remote copy up to date with the central one. For that you could just
publish a location containing the necessary files and have the users
use something like rsync directly (which is just as efficient in terms
of a binary delta) to update their own local version.

Of course, if the Subversion server is already in place so it's a
convenient server, or if more of the user base already has the client
in place, it should work just about as well.

-- David

I've got this working now, and fyi it downloads the entire zip every
time. and svn appears to be very slow at it to.
Jul 19 '05 #9
Peter Hansen <pe***@engcorp.com> writes:
Good point. When I wrote that I was picturing the form of compression
that a .tar.gz file would have, not what is actually used inside a
.zip file which is -- quite logically now that you point it out --
done on a file-by-file basis. (Clearly to do otherwise would risk
your data and make changing compressed zips highly inefficient.)


Right, and yes, .tar.gz files are very problematic for such
algorithms, such as rsync. In fact, there was a patch made available
for gzip (never made it ito the actual package I believe) that
permitted resetting the compression engine at selected block
boundaries - thus effectively bounding the "noise" generated by a
single change. The output would grow a bit since resetting the engine
dropped overall efficiency, but you got a tremendous gain back in
terms of "rsyncability" of the file.

-- David
Jul 19 '05 #10
Timothy Smith <ti*****@open-networks.net> writes:
I've got this working now, and fyi it downloads the entire zip every
time. and svn appears to be very slow at it to.


Hmm, not what I would have expected, and certainly unfortunate for
your desired use case.

I just tried some experiments with rsync (easier to test locally than
Subversion), and found that taking an existing zip, unpacking it and
then repacking it with some rearrangement was in fact sending
everything, even though the source files were unchanged. Since py2exe
is effectively rebuilding that library.zip on each run, that probably
is a fair representation of the generation process.

I'm not familiar enough with zip file compression, but perhaps it
includes the use of something that is file specific to seed the
compression engine, which would mean that making a new zip file even
with the same files in it might not yield precisely the same internal
compressed storage. Both versions would be proper and decompressible,
just not binary identical even for unchanged sources.

If I disabled compression for the zip files (just did a store only),
and rebuilt the zip even with a rearranged file order, rsync was
able to detect just the changes.

So you might want to try ensuring that your py2exe generated file is
not compressing the individual modules (a verbose zip listing of the
library.zip should just show that they were "Stored"). Your
library.zip will get larger, but it should become more efficient to
transfer - hopefully as well with Subversion as I was seeing with
rsync.

(In fact, I remember doing just something like this with a project of mine
that I was using py2exe with, and then using rsync to push out the resultant
files to remote sites - I had originally compressed the library.zip but
rsync was pushing the whole thing out, so I stopped using the compression)

-- David
Jul 19 '05 #11
>
The zip file essentially contains the whole system in on lump. Changethe system, and naturally your users will have to download the whole
lump again. [...]
but if it was just a dir, when they update from the svn at log in,

all they do is download the extra\changed files. much much quicker then
downloading a 4 meg uncompressed zip file.


Not clear what you are really asking for, but maybe this will help. I
have a application that is 95% normal code, packaged up via py2exe.
Other 5% is a few .py files in a separate directory, modified regularly
by the users (report specifications in some lists/dicts). These files
are *excluded* from the py2exe build, and I manually add this directory
to sys.path during the application startup. A change to one of the
spec files is picked up like any normal python session, and I don't
need to rebuild the entire app. Could you do the same type of thing?

Brian.

Jul 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rene Olsthoorn | last post by:
Dear readers, py2exe has a problem including libxml2. Not at building time, but at runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has the problem? (and can you drop me...
0
by: David Vaughan | last post by:
py2exe and Pmw problem ---------------------- I was really surprised not to find some faq setting out what to do to get py2exe working for a program using Pmw. I'm haemorrhaging time here, and...
1
by: mitsura | last post by:
Hi, I just installed py2exe to create a binary of my Python script. However, py2exe does not seem to create a binary from my .py script. This is what I have done: I create a setup.py script: "...
2
by: thomas carpentier | last post by:
Hello, I have created a program with a GUI ( glade). In this script I call the Python Imaging Library. I have developped this program onto linux, but il would like export it on Windows,...
3
by: Martin Evans | last post by:
I have converted a Python script using py2exe and have it set to not bundle or compress. The result is my exe and all the support files including library.zip (exactly as planned - nice job py2exe)....
5
by: Doug Morse | last post by:
Hi, I have an application that runs just fine using the standard Python distro interpreter (v2.5.1 on WinXP) but throws the following exception when run as an executable built with py2exe. My...
1
by: Jimmy Retzlaff | last post by:
py2exe 0.6.8 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python...
0
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
3
by: MyPetSlug | last post by:
Hello Guys, Using Pythong 2.4 and py2exe 0.6.6. So, I've created a wxPython application that I use for testing. The idea is to have a tests directory so that every time the application starts, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.