minimum python for distribution on Windows

Markku Hänninen hmm at iki.fi
Thu Mar 20 14:09:13 CET 2003


bobnotbob at byu.edu (Bob Roberts) writes:
> 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)?
> 
> I tried just copying my source code, python.exe, and the modules I use
> into a new directory, but it keeps complaining about not having a lot
> of modules, such as "site", that I never imported.

I have been doing this with Tools/freeze/freeze.py but py2exe might be
actually better. Anyway, instead of freezing your own script, try freezing
this to get a single-file python interpreter:

#!/usr/bin/env python

# add here all the modules your script will use
import sys, os

sys.argv=sys.argv[1:]
if len(sys.argv):
    # the first argument is the name of the script to run
    execfile(sys.argv[0]) 
else:
    # no arguments, start interactive interpreter
    code.interact()



The downside is of course, that you must list all the modules you are 
going to need beforehand in this script. 

I have done a product installation script using this method, you can
start python directly from the install-directory by just something
like: "./spython install.py". Of course the whole install.py can be frozen,
but this way it is more easy to change and debug.

I have made a small page about this technic at 
http://www.hmm.iki.fi/~hmm/python/spython.html 


-- 
   Markku Hänninen     /
     hmm at iki.fi       /   "Actually it works, it just doesn't look that way." 




More information about the Python-list mailing list