Пример #1
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        root = ctx.top_node
        while root.height() > 0:
            root = root.parent

        default_scheme = get_default_scheme(ctx.pkg.name)
        default_prefix = default_scheme["prefix"]
        default_sitedir = default_scheme["sitedir"]

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        name = ipkg.meta["name"]
        version = ipkg.meta["version"]
        py_short = ".".join([str(i) for i in sys.version_info[:2]])
        mpkg_name = "%s-%s-py%s.mpkg" % (name, version, py_short)

        categories = set()
        file_sections = ipkg.resolve_paths(ctx.build_node)
        for kind, source, target in iter_files(file_sections):
            categories.add(kind)

        # Mpkg metadata
        mpkg_root = os.path.join(os.getcwd(), "dist", mpkg_name)
        mpkg_cdir = os.path.join(mpkg_root, "Contents")
        if os.path.exists(mpkg_root):
            shutil.rmtree(mpkg_root)
        os.makedirs(mpkg_cdir)
        f = open(os.path.join(mpkg_cdir, "PkgInfo"), "w")
        try:
            f.write("pmkrpkg1")
        finally:
            f.close()
        mpkg_info = MetaPackageInfo.from_ipkg(ipkg)

        purelib_pkg = "%s-purelib-%s-py%s.pkg" % (name, version, py_short)
        scripts_pkg = "%s-scripts-%s-py%s.pkg" % (name, version, py_short)
        datafiles_pkg = "%s-datafiles-%s-py%s.pkg" % (name, version, py_short)
        mpkg_info.packages = [purelib_pkg, scripts_pkg, datafiles_pkg]
        make_mpkg_plist(mpkg_info, os.path.join(mpkg_cdir, "Info.plist"))

        mpkg_rdir = os.path.join(mpkg_root, "Contents", "Resources")
        os.makedirs(mpkg_rdir)
        make_mpkg_description(mpkg_info, os.path.join(mpkg_rdir, "Description.plist"))

        # Package the stuff which ends up into site-packages
        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", purelib_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["pythonfiles"], "Pure Python modules and packages")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", scripts_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["executables"], "Scripts and binaries")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", datafiles_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["bentofiles", "datafiles"], "Data files")
Пример #2
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        if o.dry_run:
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = ctx.get_paths_scheme()
        ipkg.update_paths(scheme)
        node_sections = ipkg.resolve_paths_with_destdir(ctx.build_node)

        if o.list_files:
            # XXX: this won't take into account action in post install scripts.
            # A better way would be to log install steps and display those, but
            # this will do for now.
            for kind, source, target in iter_files(node_sections):
                print(target.abspath())
            return

        if o.transaction:
            trans = TransactionLog("transaction.log")
            try:
                for kind, source, target in iter_files(node_sections):
                    trans.copy(source.abspath(), target.abspath(), kind)
            finally:
                trans.close()
        else:
            for kind, source, target in iter_files(node_sections):
                copy_installer(source.abspath(), target.abspath(), kind)
Пример #3
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = ctx.retrieve_configured_scheme()
        ipkg.update_paths(scheme)
        node_sections = ipkg.resolve_paths_with_destdir(ctx.build_node)

        if o.list_files:
            # XXX: this won't take into account action in post install scripts.
            # A better way would be to log install steps and display those, but
            # this will do for now.
            for kind, source, target in iter_files(node_sections):
                print(target.abspath())
            return

        if o.transaction:
            trans = TransactionLog("transaction.log")
            try:
                for kind, source, target in iter_files(node_sections):
                    trans.copy(source.abspath(), target.abspath(), kind)
            finally:
                trans.close()
        else:
            for kind, source, target in iter_files(node_sections):
                copy_installer(source.abspath(), target.abspath(), kind)
Пример #4
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        create_wininst(ipkg, src_root_node=ctx.build_node, build_node=ctx.build_node)
Пример #5
0
    def run(self, ctx):
        opts = ctx.cmd_opts
        o, a = self.parser.parse_args(opts)
        if o.help:
            self.parser.print_help()
            return

        if not os.path.exists(IPKG_PATH):
            raise UsageException("%s: error: %s subcommand require executed build" \
                    % (SCRIPT_NAME, "build_wininst"))

        ipkg = InstalledPkgDescription.from_file(IPKG_PATH)
        create_wininst(ipkg)
Пример #6
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        output_dir = o.output_dir
        output_file = o.output_file

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        build_egg(ipkg, ctx, ctx.build_node, output_dir, output_file)
Пример #7
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        output_dir = o.output_dir
        output_file = o.output_file

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        build_egg(ipkg, ctx, ctx.build_node, output_dir, output_file)
Пример #8
0
    def run(self):

        build = self.get_finalized_command("build")
        build.run()

        dist = build.distribution
        n = dist.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())

        build_node = self.distribution.build_node
        # FIXME: fix build_egg signature - we use a dummy context here to avoid
        # creating the whole command context stuff
        context = _FakeContext(build_node)
        build_egg(ipkg, context, build_node.abspath())
Пример #9
0
    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
Пример #10
0
    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
Пример #11
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        create_wininst(ipkg,
                       src_root_node=ctx.build_node,
                       build_node=ctx.build_node,
                       wininst=o.output_file,
                       output_dir=o.output_dir)
Пример #12
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        if o.output_dir is None:
            output_dir = None
        else:
            output_dir = o.output_dir

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        build_egg(ipkg, ctx, ctx.build_node, output_dir)
Пример #13
0
    def run(self, ctx):
        opts = ctx.cmd_opts
        o, a = self.parser.parse_args(opts)
        if o.help:
            self.parser.print_help()
            return

        if not os.path.exists(IPKG_PATH):
            msg = "%s file not found ! (Did you run build ?)" % IPKG_PATH
            raise UsageException(msg)

        ipkg = InstalledPkgDescription.from_file(IPKG_PATH)
        file_sections = ipkg.resolve_paths()

        for kind, source, target in iter_files(file_sections):
            copy_installer(source, target, kind)
Пример #14
0
    def write_record(self):
        dist = self.distribution

        options_context = dist.global_context.retrieve_options_context(self.cmd_name)
        cmd_context_klass = dist.global_context.retrieve_command_context(self.cmd_name)
        context = cmd_context_klass(dist.global_context, [], options_context, dist.pkg, dist.run_node)

        n = context.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = context.retrieve_configured_scheme()
        ipkg.update_paths(scheme)
        file_sections = ipkg.resolve_paths_with_destdir(src_root_node=context.build_node)

        def writer(fid):
            for kind, source, target in iter_files(file_sections):
                fid.write("%s\n" % target.abspath())
        bento.utils.io2.safe_write(self.record, writer, "w")
Пример #15
0
    def write_record(self):
        dist = self.distribution

        install = InstallCommand()
        options_context = OptionsContext.from_command(install)
        context = CmdContext([], options_context, dist.pkg, dist.run_node)
        if self.record:
            n = context.build_node.make_node(IPKG_PATH)
            ipkg = InstalledPkgDescription.from_file(n.abspath())
            scheme = context.get_paths_scheme()
            ipkg.update_paths(scheme)
            file_sections = ipkg.resolve_paths(src_root_dir=context.build_node.abspath())

            fid = open(self.record, "w")
            try:
                for kind, source, target in iter_files(file_sections):
                    fid.write("%s\n" % target)
            finally:
                fid.close()
Пример #16
0
    def write_record(self):
        dist = self.distribution

        options_context = dist.global_context.retrieve_options_context(
            self.cmd_name)
        cmd_context_klass = dist.global_context.retrieve_command_context(
            self.cmd_name)
        context = cmd_context_klass(dist.global_context, [], options_context,
                                    dist.pkg, dist.run_node)

        n = context.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = context.retrieve_configured_scheme()
        ipkg.update_paths(scheme)
        file_sections = ipkg.resolve_paths_with_destdir(
            src_root_node=context.build_node)

        def writer(fid):
            for kind, source, target in iter_files(file_sections):
                fid.write("%s\n" % target.abspath())

        bento.utils.io2.safe_write(self.record, writer, "w")
Пример #17
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        root = ctx.top_node
        while root.height() > 0:
            root = root.parent

        default_scheme = get_default_scheme(ctx.pkg.name)
        default_prefix = default_scheme["prefix"]
        default_sitedir = default_scheme["sitedir"]

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        name = ipkg.meta["name"]
        version = ipkg.meta["version"]
        py_short = ".".join([str(i) for i in sys.version_info[:2]])
        if o.output_file is None:
            mpkg_name = "%s-%s-py%s.mpkg" % (name, version, py_short)
        else:
            mpkg_name = o.output_file

        categories = set()
        file_sections = ipkg.resolve_paths(ctx.build_node)
        for kind, source, target in iter_files(file_sections):
            categories.add(kind)

        # Mpkg metadata
        mpkg_root = os.path.join(os.getcwd(), o.output_dir, mpkg_name)
        mpkg_cdir = os.path.join(mpkg_root, "Contents")
        if os.path.exists(mpkg_root):
            shutil.rmtree(mpkg_root)
        os.makedirs(mpkg_cdir)
        f = open(os.path.join(mpkg_cdir, "PkgInfo"), "w")
        try:
            f.write("pmkrpkg1")
        finally:
            f.close()
        mpkg_info = MetaPackageInfo.from_ipkg(ipkg)

        purelib_pkg = "%s-purelib-%s-py%s.pkg" % (name, version, py_short)
        scripts_pkg = "%s-scripts-%s-py%s.pkg" % (name, version, py_short)
        datafiles_pkg = "%s-datafiles-%s-py%s.pkg" % (name, version, py_short)
        mpkg_info.packages = [purelib_pkg, scripts_pkg, datafiles_pkg]
        make_mpkg_plist(mpkg_info, os.path.join(mpkg_cdir, "Info.plist"))

        mpkg_rdir = os.path.join(mpkg_root, "Contents", "Resources")
        os.makedirs(mpkg_rdir)
        make_mpkg_description(mpkg_info,
                              os.path.join(mpkg_rdir, "Description.plist"))

        # Package the stuff which ends up into site-packages
        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", purelib_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["pythonfiles"],
                            "Pure Python modules and packages")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", scripts_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["executables"],
                            "Scripts and binaries")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages",
                                datafiles_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/",
                            ["bentofiles", "datafiles"], "Data files")