Python packaged into Mac App
First, create a simple Tkinter applied, and named sandwich.py:
Import Sys
If Sys.version_info < (3, 0):
# Python 2
Import Tkinter as TK
Else
# Python 3
Import Tkinter as TK
root = Tk. Tk ()
Root.title ("Sandwich")
tk. button (root, text= "Make Me a Sandwich"). Pack ()
Tk.mainloop ()
This small application is like this:
Second, Py2app packaging
1. Create a virtualenv environment
# Create a custom directory
$ mkdir Sandwichapp
$ CD Sandwichapp
# Use Virtualenv to create a isolated environment
$ virtualenv venv
$ . Venv/bin/activate
2. Install Py2app
Pip Install Py2app
3. Generate the Setup file
Py2applet--make-setup sandwich.py
4. Packing
#自己开发, pack quickly. (Because the computer has a dependent library installed, it can be run directly)
Python setup.py py2app-a
#给其他没有sdk的电脑使用, including the Lib library. (without the SDK installed on the computer, you need to remove-A, will be all the dependencies packaged.) )
Python setup.py Py2app
reference materials
1.python packaged as an executable file app
http://blog.csdn.net/freewebsys/article/details/46683645