def __init__(self, cfg, sectnm, cnvrts): self.children = [] self._dependencies = ltoc.lTOC( ) # the stuff an outer package will need to use me self.cfg = cfg self.__name__ = 'joe' for optnm in cfg.options(sectnm): cnvrt = cnvrts.get(optnm, 'getstringlist') if cnvrt: f = getattr(self, cnvrt, None) if f: self.__dict__[optnm] = f(cfg.get(sectnm, optnm)) if not hasattr(self, 'name'): self.name = self.__name__ print "Initializing", self.__name__ self.pathprefix = autopath + self.pathprefix self.pathprefix.append(os.path.join(pyinsthome, 'support')) for z in self.zlib: if z in self.cfg.sections(): self.children.append(z) else: raise ValueError, "%s - zlib '%s' does not refer to a sections" \ % (self.name, z) for i in range(len(self.misc)): x = self.misc[i] if x in self.cfg.sections(): if self.cfg.get(x, "type") == 'PYZ': self.zlib.append(x) self.misc[i] = None self.children.append(x) self.misc = filter(None, self.misc) self.edit() self.toc = ltoc.lTOC() for thingie in self.excludes: try: fltr = tocfilter.makefilter(thingie, self.pathprefix) except ValueError: print "Warning: '%s' not found - no filter created" % thingie else: self.toc.addFilter(fltr) if self.exstdlib: self.toc.addFilter(tocfilter.StdLibFilter()) if self.extypes: self.toc.addFilter(tocfilter.ExtFilter(self.extypes)) if self.expatterns: self.toc.addFilter(tocfilter.PatternFilter(self.expatterns))
def __init__(self, cfg, sectnm, cnvrts): self.children = [] self._dependencies = ltoc.lTOC() # the stuff an outer package will need to use me self.cfg = cfg self.__name__ = 'joe' for optnm in cfg.options(sectnm): cnvrt = cnvrts.get(optnm, 'getstringlist') if cnvrt: f = getattr(self, cnvrt, None) if f: self.__dict__[optnm] = f(cfg.get(sectnm, optnm)) if not hasattr(self, 'name'): self.name = self.__name__ print "Initializing", self.__name__ self.pathprefix = autopath + self.pathprefix self.pathprefix.append(os.path.join(pyinsthome, 'support')) for z in self.zlib: if z in self.cfg.sections(): self.children.append(z) else: raise ValueError, "%s - zlib '%s' does not refer to a sections" \ % (self.name, z) for i in range(len(self.misc)): x = self.misc[i] if x in self.cfg.sections(): if self.cfg.get(x, "type") == 'PYZ': self.zlib.append(x) self.misc[i] = None self.children.append(x) self.misc = filter(None, self.misc) self.edit() self.toc = ltoc.lTOC() for thingie in self.excludes: try: fltr = tocfilter.makefilter(thingie, self.pathprefix) except ValueError: print "Warning: '%s' not found - no filter created" % thingie else: self.toc.addFilter(fltr) if self.exstdlib: self.toc.addFilter(tocfilter.StdLibFilter()) if self.extypes: self.toc.addFilter(tocfilter.ExtFilter(self.extypes)) if self.expatterns: self.toc.addFilter(tocfilter.PatternFilter(self.expatterns))
def gather(self): for script in self.script: #print "FullExeTarget.gather: script is", repr(script) rsrc = resource.makeresource(script, self.pathprefix) rsrc = resource.scriptresource(rsrc.name, rsrc.path) #print " resource is", repr(rsrc) self.toc.merge(rsrc.binaries) ArchiveTarget.gather(self) if not self.zlib: self.toc.merge(rsrc.modules) self._dependencies = ltoc.lTOC()
def gather(self): for script in self.script: #print "FullExeTarget.gather: script is", `script` rsrc = resource.makeresource(script, self.pathprefix) rsrc = resource.scriptresource(rsrc.name, rsrc.path) #print " resource is", `rsrc` self.toc.merge(rsrc.binaries) ArchiveTarget.gather(self) if not self.zlib: self.toc.merge(rsrc.modules) self._dependencies = ltoc.lTOC()
def gather(self): if self.support: # the bare minimum self.toc.merge([resource.makeresource('python20.dll')]) self.toc.merge([resource.makeresource('exceptions.pyc').asBinary()]) # zlib, bindepends, misc, trees, destdir for i in range(len(self.zlib)): # z refers to the section name z = self.zlib[i] nm = self.cfg.get(z, 'name') try: self.toc.merge([resource.makeresource(nm, ['.'])]) except ValueError: # zlibs aren't written if they turn out to be empty self.zlib[i] = None self.zlib = filter(None, self.zlib) if self.zlib: target = built.get(self.zlib[0], None) if target: self.toc.merge(target._dependencies) for script in self.bindepends: rsrc = resource.makeresource(script, self.pathprefix) self.toc.merge(rsrc.binaries) logfile.write('ltoc after bindepends:\n') pprint.pprint(self.toc.toList(), logfile) for thingie in self.misc: if thingie in self.cfg.sections(): name = self.cfg.get(thingie, "name") typ = self.cfg.get(thingie, "type") klass = self._rsrcdict.get(typ, resource.dataresource) rsrc = apply(klass, (name, name)) #now make sure we have the stuff the resource requires target = built.get(thingie, None) if target: self.toc.merge(target._dependencies) else: rsrc = resource.makeresource(thingie, self.pathprefix) self.toc.merge(rsrc.contents()) logfile.write('ltoc after misc:\n') pprint.pprint(self.toc.toList(), logfile) for script in self.script: if string.find(script, '.') == -1: script = script + '.py' rsrc = resource.makeresource(script, self.pathprefix) if rsrc.typ == 'm': rsrc.typ = 's' self.toc.merge([rsrc]) logfile.write('ltoc after scripts:\n') pprint.pprint(self.toc.toList(), logfile) for tree in self.trees: try: rsrc = resource.treeresource('.', tree) except ValueError: print "tree %s not found" % tree else: self.toc.merge(rsrc.contents()) logfile.write('ltoc after trees:\n') pprint.pprint(self.toc.toList(), logfile) self.toc.addFilter(tocfilter.TypeFilter(['d'])) logfile.write("Applying the following filters:\n") pprint.pprint(self.toc.filters, logfile) self.toc.filter() #don't dupe stuff in a zlib that's part of this target if self.zlib: ztoc = ltoc.lTOC() for zlibnm in self.zlib: target = built.get(zlibnm, None) if target: ztoc.merge(target.toc) for i in range(len(self.toc)-1, -1, -1): rsrc = self.toc[i] if isinstance(rsrc, resource.moduleresource) and rsrc in ztoc: del self.toc[i]
def gather(self): if self.support: # the bare minimum self.toc.merge([resource.makeresource('python20.dll')]) self.toc.merge( [resource.makeresource('exceptions.pyc').asBinary()]) # zlib, bindepends, misc, trees, destdir for i in range(len(self.zlib)): # z refers to the section name z = self.zlib[i] nm = self.cfg.get(z, 'name') try: self.toc.merge([resource.makeresource(nm, ['.'])]) except ValueError: # zlibs aren't written if they turn out to be empty self.zlib[i] = None self.zlib = filter(None, self.zlib) if self.zlib: target = built.get(self.zlib[0], None) if target: self.toc.merge(target._dependencies) for script in self.bindepends: rsrc = resource.makeresource(script, self.pathprefix) self.toc.merge(rsrc.binaries) logfile.write('ltoc after bindepends:\n') pprint.pprint(self.toc.toList(), logfile) for thingie in self.misc: if thingie in self.cfg.sections(): name = self.cfg.get(thingie, "name") typ = self.cfg.get(thingie, "type") klass = self._rsrcdict.get(typ, resource.dataresource) rsrc = apply(klass, (name, name)) #now make sure we have the stuff the resource requires target = built.get(thingie, None) if target: self.toc.merge(target._dependencies) else: rsrc = resource.makeresource(thingie, self.pathprefix) self.toc.merge(rsrc.contents()) logfile.write('ltoc after misc:\n') pprint.pprint(self.toc.toList(), logfile) for script in self.script: if string.find(script, '.') == -1: script = script + '.py' rsrc = resource.makeresource(script, self.pathprefix) if rsrc.typ == 'm': rsrc.typ = 's' self.toc.merge([rsrc]) logfile.write('ltoc after scripts:\n') pprint.pprint(self.toc.toList(), logfile) for tree in self.trees: try: rsrc = resource.treeresource('.', tree) except ValueError: print "tree %s not found" % tree else: self.toc.merge(rsrc.contents()) logfile.write('ltoc after trees:\n') pprint.pprint(self.toc.toList(), logfile) self.toc.addFilter(tocfilter.TypeFilter(['d'])) logfile.write("Applying the following filters:\n") pprint.pprint(self.toc.filters, logfile) self.toc.filter() #don't dupe stuff in a zlib that's part of this target if self.zlib: ztoc = ltoc.lTOC() for zlibnm in self.zlib: target = built.get(zlibnm, None) if target: ztoc.merge(target.toc) for i in range(len(self.toc) - 1, -1, -1): rsrc = self.toc[i] if isinstance(rsrc, resource.moduleresource) and rsrc in ztoc: del self.toc[i]