Thoughts on running Python zips

Colin Brown cbrown at
Fri Nov 14 05:59:21 CET 2003

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 programmatically overidden preventing
post-use access.

Colin Brown
# A generic wrapper utility for running zipped python programs
# Usage: python [-options] app_path/ [*args]
# is a package with main program named
# in directory "application". Cwd is set
# to location of app_path. sys.args has "" removed.

import os, sys

zipf = ''
for path in sys.argv:
    if path.find('') > -1:
        myself = path
    elif path.find('.zip') > -1:
        zipf = path
if zipf:
    name = os.path.splitext(os.path.basename(zipf))[0]
    exec('from '+name+' import '+name)

More information about the Python-list mailing list