Created
September 2, 2012 00:59
Build Maraschino as windows executable
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
########### EDIT ME ########### | |
# Location of Maraschino source | |
mara_dir = 'D:\\mara_exe\\source\\' | |
# Where to put the build directory | |
build_dir = 'D:\\mara_exe\\build\\' | |
# Destination of compiled Maraschino | |
dest_dir = 'D:\\mara_exe\\dest\\' | |
# Zip after build? | |
zip_build = False | |
zip_dir = 'D:\\mara_exe\\zips' | |
################################ | |
# Files to copy after compile | |
includes = { | |
'files': ['AUTHORS', 'README.md', 'Version.txt'], | |
'folders': ['static', 'templates'] | |
} | |
from distutils.core import setup | |
import py2exe, sys, os, shutil | |
# Check if Maraschino source path exists | |
if not os.path.isfile(os.path.join(mara_dir, 'Maraschino.py')): | |
quit('Could not find Maraschino.py in %s\nMake sure you have set the correct source directory' % dest_dir) | |
# set up system paths and args | |
sys.path.insert(0, mara_dir) | |
sys.path.insert(0, os.path.join(mara_dir, 'lib')) | |
sys.argv.append("py2exe") | |
# Add included libs to library.zip | |
packages = os.listdir(os.path.join(mara_dir, 'lib')) | |
packages.append('email') # werkzeug dependency | |
# Clean up old dest files | |
if os.path.exists(dest_dir): | |
shutil.rmtree(dest_dir) | |
# Compile Maraschino | |
setup( | |
name='Maraschino', | |
zipfile='lib/library.zip', | |
options={ | |
'build': {'build_base': build_dir}, | |
'py2exe': { | |
'dist_dir': dest_dir, | |
'compressed': 0, | |
'optimize': 2, | |
'dll_excludes': ['w9xpopen.exe'], | |
'bundle_files': 2, | |
'excludes': [ | |
'pywin', | |
'pywin.debugger', | |
'pywin.debugger.dbgcon', | |
'pywin.dialogs', | |
'pywin.dialogs.list', | |
'Tkconstants', | |
'Tkinter', | |
'tcl' | |
], | |
'packages': packages, | |
} | |
}, | |
console=[os.path.join(mara_dir, 'Maraschino.py')] | |
) | |
# Copy files to compiled dir | |
for f in includes['files']: | |
shutil.copy2(os.path.join(mara_dir, f), os.path.join(dest_dir, f)) | |
# Copy folders to compiled dir | |
for f in includes['folders']: | |
shutil.copytree(os.path.join(mara_dir, f), os.path.join(dest_dir, f)) | |
# Build zip file if enabled | |
if zip_build: | |
print '\n\nMaking .zip file' | |
version_file = os.path.join(dest_dir, 'Version.txt') | |
if os.path.isfile(version_file): | |
f = open(version_file, 'r') | |
version_hash = f.read() | |
f.close() | |
zip_filename = 'Maraschino-%s' % version_hash[:7] | |
else: | |
import datetime | |
now = datetime.datetime.now() | |
zip_filename = 'Maraschino-%s' % now.strftime('%d-%m-%Y') | |
if not os.path.exists(zip_dir): | |
os.makedirs(zip_dir) | |
os.chdir(zip_dir) | |
shutil.make_archive(base_name=zip_filename, format='zip', root_dir=dest_dir) | |
print '\n\nBuild Complete' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment