def zipScript( dest, main, progs = None, helps = None, compile = False
               ):  # version 2010/02/11
    """main gets renamed to __main__.py in the zip file
progs are a list of programs or modules to be included, source or compiled
helps is a list of helper modules to be included, source or compiled
"""
    tozip = []
    toremove = []
    funnymain = "__main__.py"
    
    if makeCheck( dest, (main,)) \
            or makeCheck( dest, progs ) \
            or makeCheck( dest, helps ):        
        # only if it is out of date

        import zipfile
        zf = zipfile.ZipFile( dest, "w", zipfile.ZIP_DEFLATED )

        if compile:
            import py_compile
            ixc = funnymain + "c"
            toremove.append( ixc )
            tozip.append( ixc )
            py_compile.compile( main, ixc, doraise = True )
            for ix in progs:
                ixc = ix + "c"
                toremove.append( ixc )
                tozip.append( ixc )
                py_compile.compile( ix, ixc, doraise = True )
            for ix in helps:
                ixc = ix + "c"
                toremove.append( ixc )
                tozip.append( ixc )
                py_compile.compile( ix, ixc, doraise = True )
        else:
            for ix in progs:
                tozip.append( ix )
            for ix in helps:
                tozip.append( ix )
            zf.write( ix, funnymain )

        for ix in tozip:
            zf.write( ix )
        zf.close()

        for ix in toremove:
            os.remove( ix )
main gets renamed to __main__.py in the zip file
progs are a list of programs or modules to be included, source or compiled
helps is a list of helper modules to be included, source or compiled

recipes/Python/577042_ZipScript_Build_directly_executable_zipped/recipe-577042.py