def build_egg(ipkg, source_root=".", path=None): meta = PackageMetadata.from_ipkg(ipkg) egg_info = EggInfo.from_ipkg(ipkg) # FIXME: fix egg name if path is None: egg = egg_filename(os.path.join("dist", meta.fullname)) else: egg = egg_filename(os.path.join(path, meta.fullname)) ensure_dir(egg) egg_info = EggInfo.from_ipkg(ipkg) zid = compat.ZipFile(egg, "w", compat.ZIP_DEFLATED) try: for filename, cnt in egg_info.iter_meta(): zid.writestr(os.path.join("EGG-INFO", filename), cnt) ipkg.path_variables["sitedir"] = "." file_sections = ipkg.resolve_paths(source_root) for kind, source, target in iter_files(file_sections): if not kind in ["executables"]: zid.write(source, target) pprint("PINK", "Byte-compiling ...") for kind, source, target in iter_files(file_sections): if kind in ["pythonfiles"]: zid.writestr("%sc" % target, bcompile(source)) finally: zid.close() return
def create_wininst(ipkg, egg_info=None, src_root_dir=".", wininst=None): meta = PackageMetadata.from_ipkg(ipkg) if egg_info is None: egg_info = EggInfo.from_ipkg(ipkg) # XXX: do this correctly, maybe use same as distutils ? if wininst is None: wininst = wininst_filename(os.path.join("dist", meta.fullname)) ensure_dir(wininst) egg_info_dir = os.path.join("PURELIB", egg_info_dirname(meta.fullname)) fid, arcname = tempfile.mkstemp(prefix="zip") zid = compat.ZipFile(arcname, "w", compat.ZIP_DEFLATED) try: for filename, cnt in egg_info.iter_meta(): zid.writestr(os.path.join(egg_info_dir, filename), cnt) ipkg.path_variables["bindir"] = "SCRIPTS" ipkg.path_variables["sitedir"] = "PURELIB" ipkg.path_variables["gendatadir"] = "$sitedir" file_sections = ipkg.resolve_paths(src_root_dir) def write_content(source, target, kind): zid.write(source, target) for kind, source, target in iter_files(file_sections): write_content(source, target, kind) finally: zid.close() os.close(fid) create_exe(ipkg, arcname, wininst)
def build_egg(ipkg, ctx, source_root, path=None): meta = PackageMetadata.from_ipkg(ipkg) egg_info = EggInfo.from_ipkg(ipkg) # FIXME: fix egg name if path is None: egg = egg_filename(os.path.join("dist", meta.fullname)) else: egg = egg_filename(os.path.join(path, meta.fullname)) ensure_dir(egg) egg_info = EggInfo.from_ipkg(ipkg) zid = compat.ZipFile(egg, "w", compat.ZIP_DEFLATED) try: ipkg.update_paths({"prefix": ".", "eprefix": ".", "sitedir": "."}) for filename, cnt in egg_info.iter_meta(ctx.build_node): zid.writestr(os.path.join("EGG-INFO", filename), cnt) file_sections = ipkg.resolve_paths(source_root) for kind, source, target in iter_files(file_sections): if not kind in ["executables"]: zid.write(source, target) pprint("PINK", "Byte-compiling ...") for kind, source, target in iter_files(file_sections): if kind in ["pythonfiles"]: try: bytecode = bcompile(source) except PyCompileError, e: warnings.warn("Error byte-compiling %r" % source) else: zid.writestr("%sc" % target, bcompile(source)) finally: zid.close() return
def run(self): self.run_command("build") dist = self.distribution n = dist.build_node.make_node(IPKG_PATH) ipkg = BuildManifest.from_file(n.abspath()) egg_info = EggInfo.from_ipkg(ipkg, dist.build_node) egg_info_dir = op.join(self.egg_base, "%s.egg-info" % dist.pkg.name) try: os.makedirs(egg_info_dir) except OSError, e: if e.errno != 17: raise
def run(self): self.run_command("build") dist = self.distribution n = dist.build_node.make_node(IPKG_PATH) ipkg = InstalledPkgDescription.from_file(n.abspath()) egg_info = EggInfo.from_ipkg(ipkg, dist.build_node) egg_info_dir = op.join(self.egg_base, "%s.egg-info" % dist.pkg.name) try: os.makedirs(egg_info_dir) except OSError, e: if e.errno != 17: raise
def create_wininst(ipkg, src_root_node, build_node, egg_info=None, wininst=None, output_dir=None): meta = PackageMetadata.from_ipkg(ipkg) if egg_info is None: egg_info = EggInfo.from_ipkg(ipkg, build_node) # XXX: do this correctly, maybe use same as distutils ? if wininst is None: wininst = os.path.join(output_dir, wininst_filename(meta)) else: wininst = os.path.join(output_dir, wininst) bento.utils.path.ensure_dir(wininst) egg_info_dir = os.path.join("PURELIB", egg_info_dirname(meta.fullname)) fid, arcname = tempfile.mkstemp(prefix="zip") zid = compat.ZipFile(arcname, "w", compat.ZIP_DEFLATED) try: for filename, cnt in egg_info.iter_meta(build_node): zid.writestr(os.path.join(egg_info_dir, filename), cnt) wininst_paths = compat.defaultdict(lambda: r"DATA\share\$pkgname") wininst_paths.update({ "bindir": "SCRIPTS", "sitedir": "PURELIB", "gendatadir": "$sitedir" }) d = {} for k in ipkg._path_variables: d[k] = wininst_paths[k] ipkg.update_paths(d) file_sections = ipkg.resolve_paths(src_root_node) def write_content(source, target, kind): zid.write(source.abspath(), target.abspath()) for kind, source, target in iter_files(file_sections): write_content(source, target, kind) finally: zid.close() os.close(fid) create_exe(ipkg, arcname, wininst)
def build_egg(ipkg, ctx, source_root, output_dir=None, output_file=None): meta = PackageMetadata.from_ipkg(ipkg) egg_info = EggInfo.from_ipkg(ipkg, ctx.build_node) # FIXME: fix egg name if output_dir is None: if output_file is None: egg = egg_filename(os.path.join("dist", meta.fullname)) else: egg = os.path.join("dist", output_file) else: if output_file is None: egg = egg_filename(os.path.join(output_dir, meta.fullname)) else: egg = os.path.join(output_dir, output_file) bento.utils.path.ensure_dir(egg) zid = compat.ZipFile(egg, "w", compat.ZIP_DEFLATED) try: ipkg.update_paths({ "prefix": source_root.abspath(), "eprefix": source_root.abspath(), "sitedir": source_root.abspath() }) for filename, cnt in egg_info.iter_meta(ctx.build_node): zid.writestr(os.path.join("EGG-INFO", filename), cnt) file_sections = ipkg.resolve_paths(source_root) for kind, source, target in iter_files(file_sections): if not kind in ["executables"]: zid.write(source.abspath(), target.path_from(source_root)) pprint("PINK", "Byte-compiling ...") for kind, source, target in iter_files(file_sections): if kind in ["pythonfiles"]: try: bytecode = bcompile(source.abspath()) except PyCompileError: e = extract_exception() warnings.warn("Error byte-compiling %r" % source.abspath()) else: zid.writestr("%sc" % target.path_from(source_root), bcompile(source.abspath())) finally: zid.close() return
def build_egg(ipkg, ctx, source_root, output_dir=None, output_file=None): meta = PackageMetadata.from_ipkg(ipkg) egg_info = EggInfo.from_ipkg(ipkg, ctx.build_node) # FIXME: fix egg name if output_dir is None: if output_file is None: egg = egg_filename(os.path.join("dist", meta.fullname)) else: egg = os.path.join("dist", output_file) else: if output_file is None: egg = egg_filename(os.path.join(output_dir, meta.fullname)) else: egg = os.path.join(output_dir, output_file) bento.utils.path.ensure_dir(egg) zid = compat.ZipFile(egg, "w", compat.ZIP_DEFLATED) try: ipkg.update_paths({"prefix": source_root.abspath(), "eprefix": source_root.abspath(), "sitedir": source_root.abspath()}) for filename, cnt in egg_info.iter_meta(ctx.build_node): zid.writestr(os.path.join("EGG-INFO", filename), cnt) file_sections = ipkg.resolve_paths(source_root) for kind, source, target in iter_files(file_sections): if not kind in ["executables"]: zid.write(source.abspath(), target.path_from(source_root)) pprint("PINK", "Byte-compiling ...") for kind, source, target in iter_files(file_sections): if kind in ["pythonfiles"]: try: bytecode = bcompile(source.abspath()) except PyCompileError: e = extract_exception() warnings.warn("Error byte-compiling %r" % source.abspath()) else: zid.writestr("%sc" % target.path_from(source_root), bcompile(source.abspath())) finally: zid.close() return
def build_egg(build_manifest, build_node, source_root, output_dir=None, output_file=None): meta = PackageMetadata.from_ipkg(build_manifest) egg_info = EggInfo.from_ipkg(build_manifest, build_node) # FIXME: fix egg name if output_dir is None: if output_file is None: egg = egg_filename(os.path.join("dist", meta.fullname)) else: egg = os.path.join("dist", output_file) else: if output_file is None: egg = egg_filename(os.path.join(output_dir, meta.fullname)) else: egg = os.path.join(output_dir, output_file) bento.utils.path.ensure_dir(egg) egg_scheme = {"prefix": source_root.abspath(), "eprefix": source_root.abspath(), "sitedir": source_root.abspath()} zid = compat.ZipFile(egg, "w", compat.ZIP_DEFLATED) try: for filename, cnt in egg_info.iter_meta(build_node): zid.writestr(os.path.join("EGG-INFO", filename), cnt) for kind, source, target in build_manifest.iter_built_files(source_root, egg_scheme): if not kind in ["executables"]: zid.write(source.abspath(), target.path_from(source_root)) if kind == "pythonfiles": try: bytecode = bcompile(source.abspath()) except PyCompileError: e = extract_exception() warnings.warn("Error byte-compiling %r" % source.abspath()) else: zid.writestr("%sc" % target.path_from(source_root), bcompile(source.abspath())) finally: zid.close() return
def create_wininst(ipkg, src_root_node, build_node, egg_info=None, wininst=None, output_dir=None): meta = PackageMetadata.from_ipkg(ipkg) if egg_info is None: egg_info = EggInfo.from_ipkg(ipkg, build_node) # XXX: do this correctly, maybe use same as distutils ? if wininst is None: wininst = os.path.join(output_dir, wininst_filename(meta)) else: wininst = os.path.join(output_dir, wininst) bento.utils.path.ensure_dir(wininst) egg_info_dir = os.path.join("PURELIB", egg_info_dirname(meta.fullname)) fid, arcname = tempfile.mkstemp(prefix="zip") zid = compat.ZipFile(arcname, "w", compat.ZIP_DEFLATED) try: for filename, cnt in egg_info.iter_meta(build_node): zid.writestr(os.path.join(egg_info_dir, filename), cnt) wininst_paths = compat.defaultdict(lambda: r"DATA\share\$pkgname") wininst_paths.update({"bindir": "SCRIPTS", "sitedir": "PURELIB", "gendatadir": "$sitedir"}) d = {} for k in ipkg._path_variables: d[k] = wininst_paths[k] ipkg.update_paths(d) file_sections = ipkg.resolve_paths(src_root_node) def write_content(source, target, kind): zid.write(source.abspath(), target.abspath()) for kind, source, target in iter_files(file_sections): write_content(source, target, kind) finally: zid.close() os.close(fid) create_exe(ipkg, arcname, wininst)
def run(self): self.run_command("build") dist = self.distribution n = dist.build_node.make_node(IPKG_PATH) ipkg = BuildManifest.from_file(n.abspath()) egg_info = EggInfo.from_ipkg(ipkg, dist.build_node) egg_info_dir = op.join(self.egg_base, "%s.egg-info" % dist.pkg.name) try: os.makedirs(egg_info_dir) except OSError: e = extract_exception() if e.errno != 17: raise for filename, cnt in egg_info.iter_meta(dist.build_node): filename = op.join(egg_info_dir, filename) fid = open(filename, "w") try: fid.write(cnt) finally: fid.close()