import modulefinder, sys, zipfile, os, shutil MAJ, MIN = sys.version_info[:2] zmode = zipfile.ZIP_DEFLATED DESTDIR = "python-for-axis" LIBDIR = DESTDIR + "/lib/python%d.%d" % (MAJ, MIN) ZIPLIB = DESTDIR + "/lib/python%d%d.zip" % (MAJ, MIN) os.system("rm -rf " + DESTDIR) os.makedirs(LIBDIR) os.mkdir(DESTDIR + "/share") z = zipfile.PyZipFile(ZIPLIB, 'w', zmode) debug = 0 exclude = ['ntpath', 'os2emxpath', 'macpath', 'dospath', 'distutils'] replace_paths = [] path = '/usr/src/emc/plat/nonrealtime/bin' mf = modulefinder.ModuleFinder(sys.path, debug, exclude, replace_paths) mf.load_file(path + "/axis") mf.load_file(path + "/emctop") mf.import_hook('site') if zmode == zipfile.ZIP_DEFLATED: mf.import_hook('zlib') if debug: mf.report() print modules = mf.modules builtins = [] unknown = [] mods = modules.keys() mods.sort() for mod in mods: file = modules[mod].__file__ path = modules[mod].__path__ if path: print "mo", mod, path, modules[mod].__dict__ z.writepy(path[0]) if modules[mod].__code__: if '__init__' in file: print "***", modules[mod] if os.path.basename(file) in ['axis', 'emctop']: continue print "py", mod, file z.writepy(file) elif file: print "so", mod shutil.copy(file, DESTDIR + "/lib/python2.3/" + os.path.basename(file)) os.chmod(DESTDIR + "/lib/python2.3/" + os.path.basename(file), 0755) os.system("strip --strip-unneeded %s" % DESTDIR + "/lib/python2.3/" + os.path.basename(file)) os.chmod(DESTDIR + "/lib/python2.3/" + os.path.basename(file), 0555) shutil.copy(sys.executable, DESTDIR + "/python") os.chmod(DESTDIR + "/python", 0755) os.system("strip --strip-unneeded " + DESTDIR + "/python") os.chmod(DESTDIR + "/python", 0555) shutil.copytree('/usr/share/axis', DESTDIR + "/share/axis") z.close() os.chmod(DESTDIR + "/lib/python23.zip", 0444)