views:

525

answers:

2

Possible Duplicate:
py2exe - generate single executable file

A friend of mine managed to pack some a Ruby script he wrote in a single exe file. When I tried to do the same thing for a Python script, with py2exe, I also got several pyd files and a dll.

Is it possible to pack a Python script with all it's DLL's and pyd files into just one exe, and get rid of the other files?

A: 

According to py2exe.org:

The --bundle or -b command line switch will create less files because binary extensions, runtime dlls, and even the Python-dll itself is bundled into the executable itself, or inside the library-archive if you prefer that.

...

Using a level of 1 includes the .pyd and .dll files into the zip-archive or the executable itself, and does the same for pythonXY.dll. The advantage is that you only need to distribute one file per exe, which will however be quite large.

There's also another little tutorial on creating a single exe which will expand DLLs into a temporary directory at runtime, then delete the tempdir when Python exits.

Mark Rushakoff
A: 

This page can probably help you. More specifically, it seems that you can achieve this by setting bundle_files to 1 and zipfile to None. I haven't tested it, and it may not work if you have additional DLL files.

The other approach on that page seems clumsy: creating an installer that will expand the project into a temporary directory before running it, and removing the temporary directory after the application terminates.

Remy Blank