cx_Freeze is the only tool I found (as of today) that is compatible with Python 3. It works great. I did have to fix the path in cxfreeze.bat due to my custom installation directory of Python 3.2. But other than that it was really simple. Just copy & paste the command from the documentation:
cxfreeze hello.py --target-dir dist
It created an executable, along with some
.pydfiles. The total size is 4.17 MB. Not bad considering the client do not need to install Python.
My next goal was to figure out how to set an icon for my executable. I created a
setup.pyaccording to the documentation, along with the help from some online examples, I was able to add the icon within 5 minutes!
However, ever since I switched to use the
setup.pymethod, it creates a
library.zipinstead of append all script files to the executable. I tried various command line options, searched online, still no luck. It was driving me crazy since I know it is possible!
I started digging into the source code of cx_Freeze. Thanks to this mail archive which gave me some ideas on what to look for, I was able to trace back in
freezer.py:363, by default it set
True. Okay. So how do I change it? After hours of research, I still cannot figure it out. I was tempted to change my local copy of cx_Freeze and hard code it to
Finally, by looking up another boolean option
"compressed", I was able to find an example, right in the samples directory! Orz
The final version of my
setup.pylook like this:
from cx_Freeze import setup, Executable executables = [ Executable("main.py", icon="logo.ico", appendScriptToExe=True, appendScriptToLibrary=False, ) ] buildOptions = dict(create_shared_zip=False) setup(name="hello", version="0.1", description="the typical 'Hello, world!' script", options=dict(build_exe=buildOptions), executables=executables, )
Hope it helps whoever want to disable the