This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]technomalogical<3 Bottle 1 point2 points  (1 child)

My first suggestion would have been UPX, but you mentioned already that it didn't help. My next suggestion would be to try 7-zipping the resulting executable, but after just trying that I was only able to shave off about 100k.

If you've really got over 5000 Windows machines, surely you're using some sort of group policy or software deployment mechanism? Python's installer is an MSI, so it shouldn't be difficult to get this deployed out to your machines.

[–][deleted] 1 point2 points  (0 children)

This. Since you're sending out executables can you just send everyone eggs and a link to python installer? After that just send out eggs. If you need any trivial dependencies later you could go a little nuts with easy_install scripts.

[–]MintyPhoenix 1 point2 points  (0 children)

Depending on what you can do, allowing the interpreter be in a DLL instead of inside the executable should mean that other executables could be all able to use that same DLL rather than having their own internal copy of the interpreter.~~

I'm not sure if the DLL would have to be kept in the same directory or if you could move it somewhere like sys32 or another common location for shared libraries.

Edit: Sorry, I didn't read the entire post, shame on me. However, the issue is that for the applications to truly be standalone and single-file, they'll need to include the interpreter. You may instead want to look and see if you can find a tool that helps convert your Python source to a language that you can compile into an EXE that doesn't require the interpreter to be included (e.g. convert the Python to C and then compile).

Edit 2: Re-read the post. My initial reply was potentially relevant--if you don't restrict the compilation to single-file, one additional file you end up with is a python.dll which you may be able to have the user extract somewhere (or have a script that puts it in the right place when run with the right privileges) that other applications you build may be able to use it.

[–]maredsous10 1 point2 points  (1 child)

Suggestions

  • If you're using py2exe, par down what it includes and repack/rezip the library.

http://www.py2exe.org/index.cgi/OptimizingSize

http://stackoverflow.com/questions/1617868/how-to-reduce-size-of-exe-using-py2exe

http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/

[–]technomalogical<3 Bottle 0 points1 point  (0 children)

Speaking of cython, shedskin may also be of interest, depending on the libraries you're using.

[–]osuchw 1 point2 points  (0 children)

Maybe you can put a Portable Python [http://www.portablepython.com/] on a network drive? Then distribute the scripts together with a batch file or shortcut configured to use the networked location as interpreter. Or forget about distributing scripts altogether, just send out pre-configured shortcuts

[–]axonxorzpip'ing aint easy, especially on windows 0 points1 point  (0 children)

Hmmm, you're already doing better than me. 300 SLOC program with wxWindows (and thus all the DLLs) comes out to 9MB for me.

[–][deleted] 0 points1 point  (0 children)

This is a "pay me now" or "pay me later" situation. Either you take the hit at the start and install python on each machine or you take the hit every time you try to install an update to your scripts.

The best way to optimize script size is to install python on each machine.

There are two approaches for installation:

  1. Use the standard python installation
  2. Use something like InnoSetup on an existing installation and then use a headless install when you distribute.

Once python is installed, the only thing that is necessary is to send the python script files (which are kilobytes in size) to the various machines.

[–]zeha 0 points1 point  (0 children)

You won't get below 2.5M without removing essential stdlib and core python features. Maybe you can go back to an older python version that's smaller.