from distutils.core import setup
import py2exe, sys, os

sys.path.append(r"build\bdist.win32\winexe\lib\PROGRAMME\PYTHON21")

#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 = "yass"         #name for exe
project_script = "startup.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 = ["images","sounds"]                 #extra files/dirs that should be copied
extra_modules = []              #any extra modules that are missing



#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',
    ]




#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))
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)

