#make standalone from distutils.core import setup import py2exe, sys, os #setup the project variables here. #i can't claim these will cover all the cases #you need, but they seem to work for all my #projects, just change as neeeded. project_name = "farblazer" #name for exe project_script = "farblazer.py" #name of base .PY icon_file = "" #a .ICO file for the .EXE optimize = 2 #0, 1, or 2; like -O and -OO dos_console = 0 #set to 1 to run in a DOS box extra_data = ['data','README.txt','COPYING.txt','THANKS.txt'] #extra files/dirs that should be copied extra_modules = [] #any extra modules that are missing excluded_modules = ['Tkinter'] #these pygame modules must be manually added #you could remove the "music" line if not using it pygame_modules = [ 'pygame.mixer_music', 'pygame.surflock', 'pygame.rwobject', 'pygame.imageext', ] #make sure we're in the correct directory fullpath = os.path.abspath(sys.argv[0]) dir = os.path.split(fullpath)[0] os.chdir(dir) #add our code to the python path sys.path.insert(0, 'code') print "path: %s" % sys.path #s = raw_input(">") #print s #create the proper commandline args args = ['py2exe', '--force', '-O'+`optimize`] args.append(dos_console and '--console' or '--windows') if icon_file: args.append('icon='+icon_file) args.append('--force-imports') args.append(','.join(pygame_modules + extra_modules)) args.append('--excludes') args.append(','.join(excluded_modules)) sys.argv[1:] = args + sys.argv[1:] #this will create the executable and all dependencies setup(name=project_name, scripts=[project_script]) #also need to hand copy the default font here import pygame.font, os, shutil src = os.path.split(pygame.font.__file__)[0] + '\\bluebold.ttf' dst = os.path.join('dist', project_name, 'bluebold.ttf') print 'copying:', src, '->', dst shutil.copyfile(src, dst) #also copy any extra specified files/dirs for data in extra_data: if os.path.isdir(data): dst = os.path.join('dist', project_name, data) print 'copying:', data, '->', dst shutil.copytree(data, dst) elif os.path.isfile(data): dst = os.path.join('dist', project_name, data) print 'copying:', data, '->', dst shutil.copyfile(data, dst)