def copy_framework(self, info): dest = os.path.join(self.dest, info['shortname'] + '.framework') destfn = os.path.join(self.dest, info['name']) src = os.path.join(info['location'], info['shortname'] + '.framework') if not os.path.exists(dest): self.mergetree(src, dest) self.pending.append((destfn, iter_platform_files(dest))) return destfn
def copy_framework(self, info): dest = os.path.join(self.dest, info["shortname"] + ".framework") destfn = os.path.join(self.dest, info["name"]) src = os.path.join(info["location"], info["shortname"] + ".framework") if not os.path.exists(dest): self.mergetree(src, dest) self.pending.append((destfn, iter_platform_files(dest))) return destfn
def run(self, platfiles=None, contents=None): mm = self.mm if contents is None: contents = '@executable_path/..' if platfiles is None: platfiles = iter_platform_files(self.base) for fn in platfiles: mm.run_file(fn) while self.pending: fmwk, files = self.pending.popleft() ref = mm.findNode(fmwk) for fn in files: mm.run_file(fn, caller=ref) changemap = {} skipcontents = os.path.join(os.path.dirname(self.dest), '') machfiles = [] for node in mm.flatten(has_filename_filter): machfiles.append(node) dest = os.path.join(contents, os.path.normpath(node.filename[len(skipcontents):])) changemap[node.filename] = dest def changefunc(path): res = mm.locate(path) rv = changemap.get(res) if rv is None and path.startswith('@loader_path/'): rv = changemap.get(mm.locate(mm.trans_table.get((node.filename, path)))) return rv for node in machfiles: fn = mm.locate(node.filename) if fn is None: continue rewroteAny = False for header in node.headers: if node.rewriteLoadCommands(changefunc): rewroteAny = True if rewroteAny: old_mode = flipwritable(fn) try: with open(fn, 'rb+') as f: for header in node.headers: f.seek(0) node.write(f) f.seek(0, 2) f.flush() finally: flipwritable(fn, old_mode) allfiles = [mm.locate(node.filename) for node in machfiles] return set(filter(None, allfiles))
def run(self, platfiles=None, contents=None): mm = self.mm if contents is None: contents = '@executable_path/..' if platfiles is None: platfiles = iter_platform_files(self.base) for fn in platfiles: mm.run_file(fn) while self.pending: fmwk, files = self.pending.popleft() ref = mm.findNode(fmwk) for fn in files: mm.run_file(fn, caller=ref) changemap = {} skipcontents = os.path.join(os.path.dirname(self.dest), '') machfiles = [] for node in mm.flatten(has_filename_filter): machfiles.append(node) dest = os.path.join(contents, node.filename[len(skipcontents):]) changemap[node.filename] = dest def changefunc(path): res = mm.locate(path) return changemap.get(res) for node in machfiles: fn = mm.locate(node.filename) if fn is None: continue rewroteAny = False for header in node.headers: if node.rewriteLoadCommands(changefunc): rewroteAny = True if rewroteAny: f = writablefile(fn, 'rb+') for header in node.headers: f.seek(0) node.write(f) f.seek(0, 2) f.flush() f.close() allfiles = [mm.locate(node.filename) for node in machfiles] return set(filter(None, allfiles))
def run(self, platfiles=None, contents=None): mm = self.mm if contents is None: contents = "@executable_path/.." if platfiles is None: platfiles = iter_platform_files(self.base) for fn in platfiles: mm.run_file(fn) while self.pending: fmwk, files = self.pending.popleft() ref = mm.findNode(fmwk) for fn in files: mm.run_file(fn, caller=ref) changemap = {} skipcontents = os.path.join(os.path.dirname(self.dest), "") machfiles = [] for node in mm.flatten(has_filename_filter): machfiles.append(node) dest = os.path.join( contents, os.path.normpath( node.filename[len(skipcontents):]), # noqa: E203 ) changemap[node.filename] = dest def changefunc(path): if path.startswith("@loader_path/"): # This is a quick hack for py2app: In that # usecase paths like this are found in the load # commands of relocatable wheels. Those don't # need rewriting. return path res = mm.locate(path) rv = changemap.get(res) if rv is None and path.startswith("@loader_path/"): rv = changemap.get( mm.locate(mm.trans_table.get((node.filename, path)))) return rv for node in machfiles: fn = mm.locate(node.filename) if fn is None: continue rewroteAny = False for _header in node.headers: if node.rewriteLoadCommands(changefunc): rewroteAny = True if rewroteAny: old_mode = flipwritable(fn) try: with open(fn, "rb+") as f: for _header in node.headers: f.seek(0) node.write(f) f.seek(0, 2) f.flush() finally: flipwritable(fn, old_mode) allfiles = [mm.locate(node.filename) for node in machfiles] return set(filter(None, allfiles))