[Tutor] py2exe

Alberto Troiano albertito_g at hotmail.com
Mon Jul 11 14:59:23 CEST 2005


Hey all

I had some problems with this module too but I aas able with your help to 
make a script that works
Here it is:

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

sys.argv.append('py2exe')
##setup(
##    windows = [{'script': "NovusExtension.pyw"}],
##)
setup(
    console = [{'script': "front-end.py"}],
)


The commented part is for GUI scripts (Graphic User Interface)
The uncommented part is for CLI scripts (Command Line Interface)
This works 100% sure. I use this piece in all my scripts to make them 
executable over Windows. Never tried with pygame though but I think it is 
the same. The script doesn't need to be run from command line, but if you 
want to see if there is some error, you'll have to (not mandatory I think 
you could add a try statement to the code)
If you have Pmw, then you have to freeze Pmw first. IIf this is the case 
reply to me, there is a case opened for that and I'll be glad to forward the 
answer

Best Regards to all

Alberto
>From: jfouhy at paradise.net.nz
>To: Python tutor <tutor at python.org>
>Subject: Re: [Tutor] py2exe
>Date: Sat, 09 Jul 2005 22:15:44 +1200 (NZST)
>
>Quoting "D. Hartley" <denise.hartley at gmail.com>:
>
> > I modified the setup.py file to match the details of my game (as best
> > I can imagine: I don't know what "optimize = 2 #0,
> > 1, or 2; like -O and -OO" means, so I just left it as his sample had
> > it,
>
> >From python -h:
>
>-O     : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)
>-OO    : remove doc-strings in addition to the -O optimizations
>
>optimize=2 means py2exe will optimize the bytecode and remove doc strings; 
>this
>is probably OK since you're not going to be running the debugger on your
>finished executable.
>
> > and I'm not sure if I put in all of the module names it will need
> > specified, but it looks as if its supposed to give me an error if it
> > can't find them).
>
>py2exe will search for all the modules it thinks it needs, but sometimes it 
>will
>miss some.  Generally, the best way to find out if it missed anything is to 
>run
>your executable and see if it crashes :-)
>
> > But then the tutorial says "simply run this script
> > and it will do all the work.
>
>You need to run it from the command line: python setup.py py2exe
>
>HTH.
>
>--
>John.
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor


Gaucho




More information about the Tutor mailing list