for name, mod in finder.modules.items():
    filename = mod.__file__
if filename is None:
    continue
if 'python' in filename.lower():
    continue
subprocess.call('"%s" -OO -m py_compile "%s"' % (python_exe, filename))
zipfile.write(filename, dest_path)
Cross-platform alternative to py2exe