示例#1
0
    def __init__(self, logger, execution_manager, plugin_loader=None):
        self.logger = logger
        self.execution_manager = execution_manager
        if not plugin_loader:
            self.plugin_loader = DispatchingPluginLoader(
                self.logger, BuiltinPluginLoader(self.logger),
                DownloadingPluginLoader(self.logger))
        else:
            self.plugin_loader = plugin_loader

        self._plugins = []

        self._pending_plugin_installs = []
        self._plugins_imported = set()

        self._deferred_plugins = ModuleTraversalTree()

        self._deferred_import = False

        self.project = None
        self.project_module = None

        self._tools = []

        python_env_registry = self._python_env_registry = PythonEnvRegistry(
            self)
        system_pyenv = PythonEnv(sys.exec_prefix, self).populate()
        python_env_registry["system"] = system_pyenv

        self._sys_path_original = list(sys.path)
示例#2
0
def create_venvs(logger, project, reactor):
    log_dir = project.expand_path("$dir_install_logs")
    logger.debug("Creating log directory '%s'", log_dir)
    mkdir(log_dir)

    per = reactor.python_env_registry
    system_env = per["system"]
    if not project.no_venvs:
        venv_dependencies_map = project.get_property("venv_dependencies")
        if "build" not in venv_dependencies_map:
            venv_dependencies_map["build"] = as_list(project.build_dependencies) + as_list(project.dependencies)
        if "test" not in venv_dependencies_map:
            venv_dependencies_map["test"] = as_list(project.dependencies)

        clear = project.get_property("refresh_venvs") or system_env.is_pypy
        for venv_name in project.get_property("venv_names"):
            venv_dir = project.expand_path("$dir_target/venv", venv_name,
                                           system_env.versioned_dir_name)
            logger.info("Creating target '%s' VEnv in '%s'%s", venv_name, venv_dir, " (refreshing)" if clear else "")
            per[venv_name] = current_env = PythonEnv(venv_dir, reactor).create_venv(with_pip=True,
                                                                                    symlinks=system_env.venv_symlinks,
                                                                                    clear=clear,
                                                                                    offline=project.offline)
            venv_dependencies = venv_dependencies_map.get(venv_name)
            if venv_dependencies:
                install_log_path = project.expand_path("$dir_install_logs", "venv_%s_install_logs" % venv_name)
                constraints_file_name = project.get_property("install_dependencies_constraints")
                current_env.install_dependencies(venv_dependencies,
                                                 install_log_path=install_log_path,
                                                 local_mapping={},
                                                 constraints_file_name=constraints_file_name)
    else:
        for venv_name in project.get_property("venv_names"):
            per[venv_name] = system_env
示例#3
0
    def _setup_plugin_directory(self, reset_plugins):
        per = self.python_env_registry
        system_env = per["system"]
        plugin_dir = self._plugin_dir = np(
            jp(self.project.basedir, ".pybuilder", "plugins",
               system_env.versioned_dir_name))

        self.logger.debug("Setting up plugins VEnv at '%s'%s", plugin_dir,
                          " (resetting)" if reset_plugins else "")
        plugin_env = per["pybuilder"] = PythonEnv(
            plugin_dir, self).create_venv(with_pip=True,
                                          symlinks=system_env.venv_symlinks,
                                          upgrade=True,
                                          clear=(reset_plugins
                                                 or system_env.is_pypy),
                                          offline=self.project.offline)

        prepend_env_to_path(plugin_env, sys.path)
        patch_mp_pyb_env(plugin_env)