PY2EXE - Strange Things a-Happenin

Lucas Raab pythongnome at hotmail.com
Wed Apr 28 08:11:16 EDT 2004


"Funduk" <fun.duk at rogers.com> wrote in message
news:7490e644.0404271717.28a4c7b4 at posting.google.com...
> Hello,
>
> So I've been playing with Python and Pygame for a while and I decided
> I wanted to make a real executable so I could send that stuff over to
> my friends to show off my <sarcasm>maad skillz</sarcasm>.
>
> Everything was going great I went and got all the newest software
> (including Distutils and PY2EXE) and read the docs on making a setup
> py.
>
> Following is my setup.py: Sorry if It's a little long:
> ---------------------------------------------------------
> #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 = "cards.py"     #name of starting .PY
> icon_file = ""         #ICO file for the .EXE (not working well)
> optimize = 2         #0, 1, or 2; like -O and -OO
> dos_console = 0         #set to 0 for no dos shell when run
> extra_data = ['readme.txt'] #extra files/dirs copied to game
> extra_modules = ['pygame.locals']   #extra python modules not auto
> 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') + '"'
> #unfortunately, this cool icon stuff doesn't work in current py2exe :(
> #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))
> #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 got this from some 'here's how to make a setupfile site'. I started
> using this one after the one I made caused me errors... Unfortunately
> this one does the same.
>
> I'm using IDLE (but I did also try this in the cmd prompt) so I got
> ahead and F5 this setup file and it goes ahead and haks away for a few
> seconds (on my pos pII 450). Shortly I recieve this block of
> statements and errors:
>
> Traceback (most recent call last):
>   File "C:\Documents and Settings\Administrator\My
> Documents\Projects\Pygame Projects\Cards\pygame2exe.py", line 48, in
> -toplevel-
>     setup(name=project_name, scripts=[script])
>   File "C:\DOCUME~1\ADMINI~1\MYDOCU~1\Projects\Python\distutils\core.py",
> line 101, in setup
>     _setup_distribution = dist = klass(attrs)
>   File
"C:\DOCUME~1\ADMINI~1\MYDOCU~1\Projects\Python\Lib\site-packages\py2exe\__in
it__.py",
> line 75, in __init__
>     distutils.dist.Distribution.__init__(self, attrs)
>   File "C:\DOCUME~1\ADMINI~1\MYDOCU~1\Projects\Python\distutils\dist.py",
> line 130, in __init__
>     setattr(self, method_name, getattr(self.metadata, method_name))
> AttributeError: DistributionMetadata instance has no attribute
> 'get___doc__'
>
>
> I looked up the last line in google and found a few posts noting the
> same difficulties and I was led to believe that it was some kind of
> 'mistake'...
>
> ...
>
> needless to say I was confused. I decided I could write a pretty good
> cry for help (including lots of info etc) so I am now asking you for
> help.
>
> All I want to do is make my stupid little program an executable! :)
> HELP!!!
>
> Extra Info:
> Python Version:2.3.3
> Pygame Version:1.6
> Distutils Version:1.0.2
> PY2EXE Version:0.5.0
> OS: Windows 2000 Pro
>
> Thanks in advance!!!

You say you used the command prompt, but in what way?? Did you type in
"python setup.py py2exe"?? Adding the "py2exe" is what tells python to use
py2exe along with importing it into your setup script. You can't run your
setup script using IDLE or the interactive interpreter. It has to be run
from the command line.





More information about the Python-list mailing list