Пример #1
0
    def __init__(self,
                 command_data_db,
                 commands_registry=None,
                 contexts_registry=None,
                 options_registry=None,
                 commands_scheduler=None):
        self._commands_registry = commands_registry or CommandRegistry()
        self._contexts_registry = contexts_registry or ContextRegistry()
        self._options_registry = options_registry or OptionsRegistry()
        self._scheduler = commands_scheduler or CommandScheduler()
        self._hooks_registry = HookRegistry()

        self.backend = None
        self._package_options = None

        self._command_data_db = command_data_db
        if command_data_db is None:
            self._command_data_store = {}
        else:
            self._command_data_store = read_or_create_dict(
                command_data_db.abspath())
Пример #2
0
def main(argv=None):
    if hasattr(os, "getuid"):
        if os.getuid() == 0:
            pprint(
                "RED",
                "Using bentomaker under root/sudo is *strongly* discouraged - do you want to continue ? y/N"
            )
            ans = input()
            if not ans.lower() in ["y", "yes"]:
                raise bento.errors.UsageException(
                    "bentomaker execution canceld (not using bentomaker with admin privileges)"
                )

    if argv is None:
        argv = sys.argv[1:]

    options_context = create_global_options_context()
    popts = parse_global_options(options_context, argv)

    cmd_name = popts.cmd_name

    if popts.show_version:
        print(bento.__version__)
        return

    if popts.show_full_version:
        print(bento.__version__ + "git" + bento.__git_revision__)
        return

    source_root = os.path.join(os.getcwd(), os.path.dirname(popts.bento_info))
    build_root = os.path.join(os.getcwd(), popts.build_directory)

    top_node, build_node, run_node = bento.core.node.create_base_nodes(
        source_root, build_root)
    if run_node != top_node and run_node.is_src():
        raise bento.errors.UsageException(
            "You cannot execute bentomaker in a subdirectory of the source tree !"
        )
    if run_node != build_node and run_node.is_bld():
        raise bento.errors.UsageException(
            "You cannot execute bentomaker in a subdirectory of the build tree !"
        )

    global_context = GlobalContext(build_node.make_node(CMD_DATA_DUMP),
                                   CommandRegistry(), ContextRegistry(),
                                   OptionsRegistry(), CommandScheduler())
    global_context.register_options_context_without_command(
        "", options_context)

    if not popts.disable_autoconfigure:
        global_context.set_before("build", "configure")
    global_context.set_before("build_egg", "build")
    global_context.set_before("build_wheel", "build")
    global_context.set_before("build_wininst", "build")
    global_context.set_before("install", "build")

    if cmd_name and cmd_name not in ["convert"]:
        return _wrapped_main(global_context, popts, run_node, top_node,
                             build_node)
    else:
        # XXX: is cached package necessary here ?
        cached_package = None
        register_stuff(global_context)
        for cmd_name in global_context.command_names():
            register_options(global_context, cmd_name)
        return _main(global_context, cached_package, popts, run_node, top_node,
                     build_node)