def addpythonmodules(module_dict): # XXX should really use macgen_rsrc.generate(), this does the same, but skips __main__ items = module_dict.items() items.sort() for name, module in items: mtype = module.gettype() if mtype not in ['module', 'package'] or name == "__main__": continue location = module.__file__ if location[-4:] == '.pyc': # Attempt corresponding .py location = location[:-1] if location[-3:] != '.py': print '*** skipping', location continue print 'Adding module "%s"' % name id, name = py_resource.frompyfile(location, name, preload=0, ispackage=mtype=='package')
def generate(output, module_dict, debug=0, preload=1): fsid = py_resource.create(output) for name, module in module_dict.items(): mtype = module.gettype() if mtype not in ['module', 'package']: continue location = module.__file__ if location[-4:] == '.pyc': # Attempt corresponding .py location = location[:-1] if location[-3:] != '.py': print '*** skipping', location continue id, name = py_resource.frompyfile(location, name, preload=preload, ispackage=mtype=='package') if debug > 0: print 'PYC resource %5d\t%s\t%s'%(id, name, location) Res.CloseResFile(fsid)
def addpythonmodules(module_dict): # XXX should really use macgen_rsrc.generate(), this does the same, but skips __main__ items = module_dict.items() items.sort() for name, module in items: mtype = module.gettype() if mtype not in ['module', 'package'] or name == "__main__": continue location = module.__file__ if location[-4:] == '.pyc': # Attempt corresponding .py location = location[:-1] if location[-3:] != '.py': print '*** skipping', location continue print 'Adding module "%s"' % name id, name = py_resource.frompyfile(location, name, preload=0, ispackage=mtype == 'package')
def generate(output, module_dict, debug=0, preload=1): fsid = py_resource.create(output) for name, module in module_dict.items(): mtype = module.gettype() if mtype not in ['module', 'package']: continue location = module.__file__ if location[-4:] == '.pyc': # Attempt corresponding .py location = location[:-1] if location[-3:] != '.py': print '*** skipping', location continue id, name = py_resource.frompyfile(location, name, preload=preload, ispackage=mtype == 'package') if debug > 0: print 'PYC resource %5d\t%s\t%s' % (id, name, location) Res.CloseResFile(fsid)
"""macgen_info - Generate PYC resource file only"""
"""BuildCGIApplet.py -- Create a CGI applet from a Python script.
"""macgen_bin - Generate application from shared libraries"""
"""Findmodulefiles - Find out where modules are loaded from.
ide_home = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE") mainfilename = os.path.join(ide_home, "PythonIDE.py") dstfilename = os.path.join(sys.exec_prefix, "Python IDE") buildtools.process(template, mainfilename, dstfilename, 1) targetref = Res.FSpOpenResFile(dstfilename, 3) Res.UseResFile(targetref) files = os.listdir(ide_home) # skip this script and the main program files = filter( lambda x: x[-3:] == '.py' and x not in ("BuildIDE.py", "PythonIDE.py"), files) # add the modules as PYC resources for name in files: print "adding", name fullpath = os.path.join(ide_home, name) id, name = py_resource.frompyfile(fullpath, name[:-3], preload=1, ispackage=0) # add W resources wresref = Res.FSpOpenResFile(os.path.join(ide_home, "Widgets.rsrc"), 1) buildtools.copyres(wresref, targetref, [], 0)
#
buildtools.DEBUG=1 template = buildtools.findtemplate() ide_home = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE") mainfilename = os.path.join(ide_home, "PythonIDE.py") dstfilename = os.path.join(sys.exec_prefix, "Python IDE") buildtools.process(template, mainfilename, dstfilename, 1) targetref = Res.FSpOpenResFile(dstfilename, 3) Res.UseResFile(targetref) files = os.listdir(ide_home) # skip this script and the main program files = filter(lambda x: x[-3:] == '.py' and x not in ("BuildIDE.py", "PythonIDE.py"), files) # add the modules as PYC resources for name in files: print "adding", name fullpath = os.path.join(ide_home, name) id, name = py_resource.frompyfile(fullpath, name[:-3], preload=1, ispackage=0) # add W resources wresref = Res.FSpOpenResFile(os.path.join(ide_home, "Widgets.rsrc"), 1) buildtools.copyres(wresref, targetref, [], 0)