Last active
October 28, 2016 08:02
-
-
Save fangdingjun/05a264c1cea12d79f32f66f852cdfbab to your computer and use it in GitHub Desktop.
build a seperate python gtk develop environment for windows, this is a open to use environment, no need to install python. run `setup.py build` and copy the build directory to an other windows, you can use python27_console.exe to run the script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# -*- coding: utf-8 -*- | |
import code | |
import os | |
import sys | |
if __name__ == "__main__": | |
libraries = ["python27.zip", "library.zip"] | |
for f in libraries: | |
f1 = os.path.abspath(f) | |
if os.path.exists(f1): | |
sys.path.insert(0, f1) | |
sys.path.append(".") | |
if len(sys.argv) > 1: | |
if os.path.exists(sys.argv[1]): | |
sys.argv = sys.argv[1:] | |
execfile(sys.argv[0]) | |
else: | |
raise OSError("No such file: %s" % sys.argv[1]) | |
else: | |
code.interact() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
import sys | |
import os | |
import glob | |
# from distutils.core import Extension | |
from cx_Freeze import setup, Executable | |
consoleBase = None | |
guiBase = None | |
if sys.platform == "win32": | |
guiBase = "Win32GUI" | |
includefiles = [] | |
for s in [ | |
"*.xml", | |
"*.ini", | |
"*.pyd", | |
"*.cfg", | |
# "*.doc", | |
# "*.docx", | |
#"*.mdb", | |
"*.json", | |
#"*.txt", | |
#"*.sql", | |
]: | |
for f in glob.glob(s): | |
includefiles.append((f, os.path.basename(f))) | |
glade_root = r'D:\Program Files\Glade Interface Designer Gtk+ 2' | |
files = ["bin/glade-3.exe", "bin/gspawn-win32-helper.exe", | |
"bin/gspawn-win32-helper-console.exe", | |
"lib", "share", "glade-3.ico", | |
] | |
for f in files: | |
includefiles.append((os.path.join(glade_root, f), os.path.basename(f))) | |
gtk_root = "e:/gtk2.24/gtk" | |
files = ["etc", "lib/gtk-2.0", "lib/gnome-vfs-2.0", "lib/GConf-dbus", | |
"lib/orbit-2.0", "share/locale/zh", "share/locale/zh_CN", | |
"share/themes", "share/icons"] | |
for f in files: | |
includefiles.append((os.path.join(gtk_root, f), f)) | |
py_modules = [ | |
"glib", "gtk", "gobject", "gio", "pango", "ctypes", | |
"types", "win32con", "win32process", "win32com.shell.shell", | |
"threading", "re", "wmi", "socket", "select", "traceback", | |
"Queue", "platform", "StringIO", "pythoncom", "pycurl2", "urllib", | |
"urllib2", "hashlib", "Crypto.Cipher.AES", "Crypto.Cipher.ARC4", | |
"Crypto.Random", "lxml.etree", "lxml._elementpath", "gtk.keysyms", | |
"time", "pymysql", "adodbapi", "ConfigParser", "json", | |
"win32net", "win32netcon", "win32wnet", "pywintypes", "telnetlib", | |
"httplib2", "urlparse", "random", "pygtk", "win32file", "nfc.ndef", | |
"smartcard.System", "smartcard.util", "xml.etree.ElementTree", | |
"win32event", "win32com.shell.shellcon", "logging", "logging.handlers" | |
] | |
setup( | |
version="0.0.1", | |
options={"build_exe": {"include_files": includefiles, | |
"excludes": ["Tkinter"], | |
"includes": py_modules, | |
"include_msvcr": True | |
}}, | |
executables=[ | |
Executable("python27.py", | |
base=consoleBase, | |
targetName="python27_console.exe", | |
icon="D:\Python27\DLLs\py.ico" | |
), | |
Executable("python27.py", | |
base=guiBase, | |
targetName="python27_gui.exe", | |
icon="D:\Python27\DLLs\py.ico", | |
), | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment