@@ -98,44 +98,47 @@ def required_tools(self) -> dict[str, list[str]]:
9898
9999 def ensure_tools_installed (self , gui ) -> bool :
100100 """
101- Check if all required tools are installed.
102- Returns True if all tools are available, False if any tool is missing.
103- This is a synchronous check - actual installation should be handled asynchronously by the UI.
101+ Check if all required tools are installed, and install missing ones.
102+ Returns True if all tools are available or installation started, False if system tool installation failed.
104103 """
105104 try :
106105 tools = self .required_tools
107106 python_tools = tools .get ('python' , [])
108107 system_tools = tools .get ('system' , [])
109108
110- # Check if VenvManager is available
109+ # Check Python tools
111110 if hasattr (gui , 'venv_manager' ) and gui .venv_manager :
112111 venv_path = gui .venv_manager .resolve_project_venv ()
113- if venv_path :
114- # Check Python tools in venv
115- if python_tools :
116- for tool in python_tools :
117- if not gui .venv_manager .is_tool_installed (venv_path , tool ):
118- if hasattr (gui , 'log' ) and gui .log :
119- gui .log .append (f"⚠️ Python tool '{ tool } ' not found in venv" )
120- return False
121-
122- # Check system tools
112+ if venv_path and python_tools :
113+ missing_python = []
114+ for tool in python_tools :
115+ if not gui .venv_manager .is_tool_installed (venv_path , tool ):
116+ missing_python .append (tool )
117+ if missing_python :
118+ if hasattr (gui , 'log' ) and gui .log :
119+ gui .log .append (f"📦 Installation des outils Python manquants: { missing_python } " )
120+ gui .venv_manager .ensure_tools_installed (venv_path , missing_python )
121+
122+ # Check and install system tools
123123 if system_tools :
124124 try :
125- from Core .sys_deps import check_system_packages
125+ from Core .sys_deps import check_system_packages , install_system_packages
126126 if not check_system_packages (system_tools ):
127127 if hasattr (gui , 'log' ) and gui .log :
128- gui .log .append (f"⚠️ System tools { system_tools } not available" )
129- return False
128+ gui .log .append (f"📦 Installation des outils système manquants: { system_tools } " )
129+ if not install_system_packages (system_tools , gui ):
130+ if hasattr (gui , 'log' ) and gui .log :
131+ gui .log .append (f"❌ Échec installation outils système: { system_tools } " )
132+ return False
130133 except Exception as e :
131134 if hasattr (gui , 'log' ) and gui .log :
132- gui .log .append (f"⚠️ Error checking system tools { system_tools } : { e } " )
135+ gui .log .append (f"⚠️ Error checking/installing system tools { system_tools } : { e } " )
133136 return False
134137
135138 return True
136139 except Exception as e :
137140 if hasattr (gui , 'log' ) and gui .log :
138- gui .log .append (f"⚠️ Error checking tools : { e } " )
141+ gui .log .append (f"⚠️ Error in ensure_tools_installed : { e } " )
139142 return False
140143
141144 def apply_i18n (self , gui , tr : dict ) -> None :
0 commit comments