Peter Hansen peter at
Mon Jan 26 20:47:19 CET 2004

Premshree Pillai wrote:
> Wrote a simple Python script that makes life a wee bit
> easier when using py2exe:
> """
> - Simple Python script to automate the creation
>   of Python executables using py2exe.
> fp = open("","w")
> temp = """from distutils.core import setup
> import py2exe
> setup(name = "%s",
>      scripts = ["%s"],
> )""" % (package,fileName)
> fp.write(temp)
> fp.close()

You could save yourself a fair bit of trouble, and avoid writing a
"" file to the filesystem (possibly overwriting an existing
one which might be important) by just calling the setup() method 
directly yourself.  The only trick is that it checks sys.argv[] for
the "py2exe" argument, so you have to fake that first:

sys.argv[1:] = ['py2exe']

from distutils.core import setup

That should do the trick....  if you're interested in integrating the
changes, and maintaining it, I'll forward our own script which you can
pull apart and reuse as required...


More information about the Python-list mailing list