Generating a single exe file from Python code
Possible duplicate:
py2exe - generate a single executable file
A friend of mine managed to put together a Ruby script package that he wrote in a single exe file. When I tried to do the same for a Python script, with py2exe, I also got some pyd files and dlls.
Is it possible to package a Python script with all dll and pyd files into one exe and get rid of the other files?
source to share
According to py2exe.org :
The --bundle or -b command line switch will create fewer files because binaries, runtime libraries, and even the Python-dll itself will be included in the executable itself or inside the archive library if you so desire.
...
Using level 1 includes the .pyd and .dll files in 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 however will be quite large.
There's also a little little tutorial on how to create a single exe that will expand the DLLs in a temporary directory at runtime and then remove the tempdir when Python exits.
source to share
This page can help you. More specifically, it seems that you can achieve this by setting bundle_files
to 1 and zipfile
to None
. I have not tested it and it may not work if you have additional dlls.
Another approach on this page seems clunky: create an installer that will expand the project into a temporary directory before launching it, and delete the temporary directory after the application finishes.
source to share