Skip to content

Commit 27e40d4

Browse files
committed
engines: séquencer proprement l'installation système puis Python
- Évite les lancements concurrents d'installation système et Python qui créaient des conflits. - Exécute d'abord la phase système, puis la phase Python dans ensure_tools_installed(). - En cas d'échec/timeout système, journalise l'erreur et enchaîne tout de même sur l'installation Python.
1 parent 169f0dc commit 27e40d4

1 file changed

Lines changed: 58 additions & 37 deletions

File tree

EngineLoader/base.py

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -161,48 +161,38 @@ def ensure_tools_installed(self, gui) -> bool:
161161
"""
162162
Check if all required tools are installed, and install missing ones.
163163
Uses direct SysDependencyManager integration for system packages with full GUI support.
164-
Returns True if all tools are available or installation started, False if system tool installation failed.
164+
System tools are processed first, then Python tools to avoid concurrent install conflicts.
165+
If system installation fails or cannot start, Python installation is still attempted.
165166
"""
166167
try:
167168
tools = self.required_tools
168169
python_tools = tools.get("python", [])
169170
system_tools = tools.get("system", [])
171+
missing_python: list[str] = []
172+
use_system_python = False
173+
python_venv_path = None
174+
can_install_python = bool(
175+
hasattr(gui, "venv_manager") and gui.venv_manager and python_tools
176+
)
170177

171-
# Check Python tools using venv_manager
172-
if hasattr(gui, "venv_manager") and gui.venv_manager and python_tools:
173-
use_system = bool(getattr(gui, "use_system_python", False))
174-
if use_system:
175-
missing_python = []
178+
# Collect missing Python tools first; actual installation is executed after system phase.
179+
if can_install_python:
180+
use_system_python = bool(getattr(gui, "use_system_python", False))
181+
if use_system_python:
176182
for tool in python_tools:
177183
if not gui.venv_manager.is_tool_installed_system(tool):
178184
missing_python.append(tool)
179-
if missing_python:
180-
log_i18n_level(
181-
gui,
182-
"info",
183-
f"Installation des outils Python manquants: {missing_python}",
184-
f"Installing missing Python tools: {missing_python}",
185-
)
186-
gui.venv_manager.ensure_tools_installed_system(missing_python)
187185
else:
188-
venv_path = gui.venv_manager.resolve_project_venv()
189-
if venv_path:
190-
missing_python = []
186+
python_venv_path = gui.venv_manager.resolve_project_venv()
187+
if python_venv_path:
191188
for tool in python_tools:
192-
if not gui.venv_manager.is_tool_installed(venv_path, tool):
189+
if not gui.venv_manager.is_tool_installed(
190+
python_venv_path, tool
191+
):
193192
missing_python.append(tool)
194-
if missing_python:
195-
log_i18n_level(
196-
gui,
197-
"info",
198-
f"Installation des outils Python manquants: {missing_python}",
199-
f"Installing missing Python tools: {missing_python}",
200-
)
201-
gui.venv_manager.ensure_tools_installed(
202-
venv_path, missing_python
203-
)
204193

205-
# Check and install system tools using direct SysDependencyManager
194+
# Check and install system tools first to avoid concurrent installs.
195+
system_phase_ok = True
206196
if system_tools:
207197
try:
208198
# Import and use SysDependencyManager directly for full GUI support
@@ -256,23 +246,23 @@ def ensure_tools_installed(self, gui) -> bool:
256246
f"Échec installation outils système: {missing_system} (code: {process.exitCode()})",
257247
f"System tools installation failed: {missing_system} (code: {process.exitCode()})",
258248
)
259-
return False
249+
system_phase_ok = False
260250
else:
261251
log_i18n_level(
262252
gui,
263253
"warning",
264254
"Timeout lors de l'installation des outils système",
265255
"Timeout during system tools installation",
266256
)
267-
return False
257+
system_phase_ok = False
268258
else:
269259
log_i18n_level(
270260
gui,
271261
"error",
272262
"Impossible de démarrer l'installation des outils système",
273263
"Unable to start system tools installation",
274264
)
275-
return False
265+
system_phase_ok = False
276266

277267
elif system == "windows":
278268
# Convert package names to winget format for Windows
@@ -319,15 +309,15 @@ def ensure_tools_installed(self, gui) -> bool:
319309
f"Échec installation Windows: {missing_system}",
320310
f"Windows installation failed: {missing_system}",
321311
)
322-
return False
312+
system_phase_ok = False
323313
else:
324314
log_i18n_level(
325315
gui,
326316
"warning",
327317
"Timeout lors de l'installation Windows",
328318
"Timeout during Windows installation",
329319
)
330-
return False
320+
system_phase_ok = False
331321
else:
332322
log_i18n_level(
333323
gui,
@@ -341,7 +331,7 @@ def ensure_tools_installed(self, gui) -> bool:
341331
"https://learn.microsoft.com/en-us/windows/package-manager/winget/"
342332
]
343333
)
344-
return False
334+
system_phase_ok = False
345335
else:
346336
log_i18n_level(
347337
gui,
@@ -356,7 +346,7 @@ def ensure_tools_installed(self, gui) -> bool:
356346
"Plateforme non supportée pour l'installation automatique",
357347
"Platform not supported for automatic installation",
358348
)
359-
return False
349+
system_phase_ok = False
360350
else:
361351
log_i18n_level(
362352
gui,
@@ -372,7 +362,38 @@ def ensure_tools_installed(self, gui) -> bool:
372362
f"Erreur lors de la vérification/installation des outils système: {e}",
373363
f"Error checking/installing system tools: {e}",
374364
)
375-
return False
365+
system_phase_ok = False
366+
367+
if not system_phase_ok:
368+
log_i18n_level(
369+
gui,
370+
"warning",
371+
"Installation système incomplète/échouée; passage à l'installation Python.",
372+
"System installation failed/incomplete; continuing with Python installation.",
373+
)
374+
375+
# Install Python tools only after system phase has ended.
376+
if can_install_python and missing_python:
377+
log_i18n_level(
378+
gui,
379+
"info",
380+
f"Installation des outils Python manquants: {missing_python}",
381+
f"Installing missing Python tools: {missing_python}",
382+
)
383+
try:
384+
if use_system_python:
385+
gui.venv_manager.ensure_tools_installed_system(missing_python)
386+
elif python_venv_path:
387+
gui.venv_manager.ensure_tools_installed(
388+
python_venv_path, missing_python
389+
)
390+
except Exception as e:
391+
log_i18n_level(
392+
gui,
393+
"warning",
394+
f"Erreur lors de l'installation des outils Python: {e}",
395+
f"Error during Python tools installation: {e}",
396+
)
376397

377398
return True
378399
except Exception as e:

0 commit comments

Comments
 (0)