minimum python for distribution on Windows

Dave Brueck dave at pythonapocrypha.com
Thu Mar 20 18:14:55 CET 2003


On Thu, 20 Mar 2003, Bob Roberts wrote:

> Dave Brueck <dave at pythonapocrypha.com> wrote:
> > On Wed, 19 Mar 2003, Bob Roberts wrote:
> >
> > > I just tried out py2exe, and it worked great.  Is it possible to do
> > > something similar, but with my python source code still available (and
> > > able to be modified)?
> >
> > IIRC py2exe has a --excludes parameter that tells it to, well, exclude the
> > module from the distribution.
>
> Thank you, that worked well.  And thank you for your Python 2.1 Bible,
> while I'm at it.

That _you_ for buying it. :)

> Is it possible to do this without py2exe?  What if I have a large
> number of scripts that use pretty much the same modules?  It would be
> nice to be able to distribute the python.exe, the libraries, and my
> scripts without having to have the python.exe bundled for each script.

Yes, you can do this - the tradeoff is mostly that you are the one
responsible for finding and including all the dependencies. The poor man's
approach is to set your PATH environment variable to be empty and rename
the directory Python is installed in and put Python.exe and your modules
in an empty directory. Run it, see what errors occur. Repeat until done.

You could also py2exe a "dispatcher" application - a front end that
chooses which of your scripts to write. Something like (untested):

import sys
import urllib, os, ... # all the standard library scripts your scripts use

execfile(sys.argv[1])

Save it as dispatch.py and run it like this:

python dispatch.py foo.py

where foo.py is the name of one of your scripts. As an exe you'd run it as
"dispatch.exe foo.py".

(by importing all the modules your scripts use you can make py2exe do the
finding-and-packaging work for you)

-Dave





More information about the Python-list mailing list