Skip to content

Commit 7fd14b7

Browse files
committed
Added tool installation checks to CompilerEngine
1 parent 08d4585 commit 7fd14b7

2 files changed

Lines changed: 25 additions & 19 deletions

File tree

Core/Compiler/mainprocess.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def start_compilation_process(self, file):
108108
except Exception as e:
109109
self.log.append(f"❌ Impossible d'instancier le moteur '{engine_id}': {e}")
110110
return
111+
# Ensure required tools are installed
112+
if not engine.ensure_tools_installed(self):
113+
return
111114
# Preflight checks
112115
if not engine.preflight(self, file):
113116
return

Core/engines_loader/base.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)