Eventually when making apps in python you run into the problem of needing to distribute executables instead of just source code. Jumping this hurdle requires you to use one of a couple libraries, the common ones being py2exe (windows only), pyinstaller (win and *nix), and cxfreeze (win, *nix, and mac). Each one works a little differently and has its own quirks. Over the years I’ve created my own little build script that uses pyinstaller or cxfreeze (which I’ll release in a GUI one day to compliment Flame) which usually works and puts things where I want them. THIS time, however, I was running into issues with pyinstaller ( which I prefer over cxfreeze because of its 1 file option) and had to use cxfreeze. Unfortunately, my easy code for making cxfreeze work basically fakes running the script itself instead of using the “python setup.py build” format the docs seem to prefer and I could not for the life of me find how to build an executable that way WITHOUT the console open in the back. However, it actually is quite simple, so I’m documenting it here both for the world and for my own reference later on down the road.
The relevant part of my script looks like this:
from cx_Freeze import main
sys.argv = [sys.argv[0], ‘–target-dir’, ‘%s’%DISTFOLDER, ‘–base’, ‘Win32GUI’, entrypoint ]
main()
You’ll need to put in your target directory for DISTFOLDER and your entry point script for entrypoint. The console-less part is as simple as the –base Win32GUI tag, but good luck finding that anywhere.
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
You must log in to post a comment.