From e13e8c53b53e623e736966ad55fee7885ea2a481 Mon Sep 17 00:00:00 2001 From: Tony Bartsits Date: Thu, 22 Feb 2024 09:26:05 +0000 Subject: [PATCH] add ca cert support for pip install --- agent/worker/task_app.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/worker/task_app.py b/agent/worker/task_app.py index e3cd7b5..ad9a72d 100644 --- a/agent/worker/task_app.py +++ b/agent/worker/task_app.py @@ -562,6 +562,7 @@ def _exec_command(self, command, add_envs=None, container_id=None): "PYTHONUNBUFFERED": "1", constants._HTTP_PROXY: constants.HTTP_PROXY(), constants._HTTPS_PROXY: constants.HTTPS_PROXY(), + constants._NO_PROXY: constants.NO_PROXY(), "HOST_TASK_DIR": self.dir_task_host, "TASK_ID": self.info["task_id"], "SERVER_ADDRESS": self.info["server_address"], @@ -602,8 +603,14 @@ def install_pip_requirements(self, container_id=None): "Installing app requirements...", 1, ext_logger=self.logger ) progress_dummy.iter_done_report() + + install_cmd_str = "pip3 install" + + if constants.SLY_EXTRA_CA_CERTS() and os.path.exists(constants.SLY_EXTRA_CA_CERTS()): + install_cmd_str += f" --cert {constants.SLY_EXTRA_CA_CERTS_FILEPATH()}" + # --root-user-action=ignore - command = "pip3 install --disable-pip-version-check -r " + os.path.join( + command = f"{install_cmd_str} --disable-pip-version-check -r " + os.path.join( self.dir_task_src_container, self._requirements_path_relative ) self.logger.info(f"PIP command: {command}")