Created
April 14, 2010 15:31
-
-
Save sobelk/365940 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Simple py2exe compilation script for Windows. With a python file handler configured, | |
drag python script on to compile_wrapper.py. Runs py2exe for that file and cleans up | |
the temporary build/dist directories. | |
Setup options may need tweaking, and there is room for optimization | |
(see http://www.py2exe.org/index.cgi/OptimizingSize). | |
Requires: | |
py2exe, http://www.py2exe.org/index.cgi/FrontPage | |
""" | |
import sys | |
import os | |
import shutil | |
from distutils.core import setup | |
import py2exe | |
if sys.argv[1:]: | |
os.chdir(os.path.dirname(sys.argv[0])) | |
path = sys.argv[1] | |
sys.argv[1] = 'py2exe' | |
setup(console=[path], | |
zipfile=None, | |
options={'py2exe': {'bundle_files': 1, | |
'compressed': 1, | |
'optimize': 1, | |
'dll_excludes': ['w9xpopen.exe'], | |
#'ascii': True # optional optimizations | |
#'excludes': ['_ssl', | |
# 'pyreadline', | |
# 'difflib', | |
# 'doctest', | |
# 'locale', | |
# 'optparse', | |
# 'pickle', | |
# 'calendar'] | |
}}) | |
print("") | |
print("Removing build directory.") | |
shutil.rmtree('build') | |
print("Moving executable into current directory.") | |
exec_name = os.path.basename(path).replace('.py', '.exe') | |
if os.path.exists(exec_name): | |
print("Deleting old executable.") | |
os.unlink(exec_name) | |
os.rename('dist/%s' % exec_name, exec_name) | |
print("Removing dist directory.") | |
shutil.rmtree('dist') | |
print("Press any key to exit.") | |
raw_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment