[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] I got pygame2exe.py working (with a small work around)



I definitely recommend something like the attached... which makes sure the
right things get stuffed into it.
Awkward when util directories are peers rather than all under a heirarchy.

The 'data' brings in the whole subtree, the individual files, e.g.
kitchen.ttf, work too.

I run this build in the parent of the game directory.

Adrian wrote:

> On 2002.02.04 10:39 Pete Shinners wrote:
> > Andrew Jones wrote:
> >> - When running the script the pygame2exe.py output said it could not
> >> find any of the .py files in the pyzzle subdirectories.
> >
> > any changes to "sys.path" don't seem to get found by py2exe very
> > well. perhaps if you added the "path" changes to the pygame2exe
> > script itself it would work, but i haven't tried to do it.
> >
>
> I've tried this, and it doesn't work. But, then again, it won't work
> with the workaround either for me. The exe spits out "Unable to import
> modules" and quits. For me it's not a big issue yet since I'm not ready
> to make a binary distributions. But adding the path in the pygame2exe
> did fix the error that said it couldn't find my main module (main.py in
> the code dir). So, I'm guessing it would work(?). Have a nice day.
>
> --Adrian
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org

--
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

mQGiBDuA04cRBADoAVeSVHfIm2vDtjzO4yAceKRIaWgZ2eLNLTf7RWi94+FflEOq
MhCJ4Y6JRQOUsWuI69njQ2iz6F/QVMMK+UrfDBkAdXoewun8JpcjnwzVG5oo8FlA
zb6Au1pTkh4rMZENUs59YWuurjO93smafh+Odvp2gz0oBQolEld+9sSZcwCg/1EU
IS1ON1TXcvzv1VMF3DWyfBkEAKoHkoRmpHzoJS4r6sbneGfA/qp/m1wyDhn5FPwv
J+/uAg1m8pGkTr7Dg8k8nog+lSUbV4cnUj+K/VluIS+mN3aavQZOgt8/CroTNiRk
b4JQbYio6gt6uW/rwMHmfgMwyIKIjRlQB1Xif6BGhzkxXKsbqWvrUypG0fsg2+Bl
d7nYBADFnYFqnE4EjX/7jKxqZ/Qwmr1buJfsYz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JEBylPoXihJTJSPcAnRPSivOU4RbzkmfvZF7RBycxm5ubAJ96QW1kGhkc13zR
ozfk3rcGqoHeWg==
=fGmQ
-----END PGP PUBLIC KEY BLOCK-----

#Make bombers
#
#PG 01feb02  Wow it works... 
#note the font was breaking it before

#Note.  When you setup a new prog. for distribution, remember to create both ./dist/<prog> and ./dist/<prog>/data

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

#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 = "bombers" #name for EXE
project_script = "bombers/bombers.py"    #name of base .PY
#unfortunately, this cool icon stuff doesn't work in current py2exe :(
icon_file = "" #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 (for debugging)
extra_data = ['kitchen.ttf','readme.txt','data'] #list of extra files/dirs copied to game
extra_modules = [] #list of extra python modules not automatically found


#use the default pygame icon, if none given
if not icon_file:
    path = os.path.split(pygame.__file__)[0]
    icon_file = '"' + os.path.join(path, 'pygame.ico') + '"'
icon_file = ''


#create the 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))
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 extra files here
def copyfile(name):
   dst = os.path.join('dist', project_name)
   print 'copying', name, '->', dst
   usename = os.path.join(project_name,name)
   if os.path.isdir(usename):
      dst = os.path.join(dst, name)
      shutil.rmtree(dst)
      shutil.copytree(usename, dst)
   elif os.path.isfile(usename):
      shutil.copy(usename, dst)
   else:
      print 'Warning, %s not found' % usename

pygamedir = os.path.split(pygame.base.__file__)[0]
for data in extra_data:
    copyfile(data)