As I am getting a larger collection of python program packages the idea of
saving them as zips is becoming increasingly attractive. The latest idea is
to launch them from a generic wrapper listed below. I have chosen to set the
default directory to the location of the zipfile because I usually have an
associated configuration inifile alongside.
Periodically the topic of program protection crops up. Some zip applications
allow password protection. If python did then one could possibly tie a
user's distribution to their network card MAC address. I guess the
commandline "-i" option could be programmaticall y overidden preventing
post-use access.
Colin Brown
PyNZ
--------------------------------------------------------------------
# A generic wrapper utility for running zipped python programs
#
# Usage: python [-options] RunZip.py app_path/application.zip [*args]
#
# application.zip is a package with main program named
# application.py in directory "applicatio n". Cwd is set
# to location of app_path. sys.args has "RunZip.py" removed.
import os, sys
zipf = ''
for path in sys.argv:
if path.find('RunZ ip.py') > -1:
myself = path
elif path.find('.zip ') > -1:
zipf = path
break
sys.argv.remove (myself)
if zipf:
sys.path.insert (0,zipf)
name = os.path.splitex t(os.path.basen ame(zipf))[0]
os.chdir(os.pat h.dirname(os.pa th.abspath(zipf )))
exec('from '+name+' import '+name)