[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Create an exe



I am trying to create a standalone Windows exe for a
game that I have created following these instructions
:-
http://pygame.seul.org/ftp/pygame2exe.py
I get these errors :-
Traceback (most recent call last):
  File "C:\Documents and Settings\david\My
Documents\birdgame\pygame2exe.py", line 50, in
-toplevel-
    setup(name=project_name, scripts=[script])
  File "C:\Python24\lib\distutils\core.py", line 137,
in setup
    raise SystemExit, gen_usage(dist.script_name) +
"\nerror: %s" % msg
SystemExit: usage: pygame2exe.py [global_opts] cmd1
[cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: pygame2exe.py --help [cmd1 cmd2 ...]
   or: pygame2exe.py --help-commands
   or: pygame2exe.py cmd --help

error: option --force not recognized


Can anyone see what I am doing wrong ?
Here is the modified script I created
#make standalone, needs at least pygame-1.5.3 and
py2exe-0.3.1

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

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


script = "birdgame44.py"	    	#name of starting .PY
#project_name = "crazybird"
#project_script = "birdgame43.py"
icon_file = ""	    	    	#ICO file for the .EXE (not
working well)
optimize = 2 	    	    	#0, 1, or 2; like -O and -OO
dos_console = 1     	    	#set to 0 for no dos shell
when run
extra_data = [ 'missile.bmp', 'explosion1.bmp',
'explosion2.bmp','explosion3.bmp','explosion4.bmp','explosion5.bmp','explosion6.bmp','explosion7.bmp','explosion8.bmp','explosion9.bmp','galaxy.gif']
#extra files/dirs copied to game
extra_modules = ['pygame.locals', 'livewires3']  
#extra python modules not auto found


 proper commandline args
args = ['py2exe', '--force', '-O'+`optimize`]
args.append(dos_console and '--console' or
'--windows')
if icon_file:
    args.append('--icon')
    args.append(icon_file)
args.append('--force-imports')
args.append(','.join(extra_modules))
#args.append(','.join(pygame_modules + extra_modules))
sys.argv[1:] = args + sys.argv[1:]

project_name =
os.path.splitext(os.path.split(script)[1])[0]


#this will create the executable and all dependencies
setup(name=project_name, scripts=[script])

#also need to hand copy the extra files here
def installfile(name):
    dst = os.path.join('dist', project_name)
    print 'copying', name, '->', dst
    if os.path.isdir(name):
        dst = os.path.join(dst, name)
        if os.path.isdir(dst):
            shutil.rmtree(dst)
        shutil.copytree(name, dst)
    elif os.path.isfile(name):
        shutil.copy(name, dst)
    else:
        print 'Warning, %s not found' % name




pygamedir = os.path.split(pygame.base.__file__)[0]
installfile(os.path.join(pygamedir,
pygame.font.get_default_font()))
installfile(os.path.join(pygamedir,
'pygame_icon.bmp'))
for data in extra_data:
    installfile(data)



I am using python 2.4 and Win XP personal.  Any ideas
?

David


	
	
		
___________________________________________________________ 
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com