1414# limitations under the License.
1515
1616"""
17- Engine Runner — pure-Python, Qt-free compilation executor.
17+ Engine Runner - pure-Python, Qt-free compilation executor.
1818
1919Source of truth for how ARK loads an engine and runs a compilation
2020against a BuildContext. Both the CLI (Ui/Cli/spec_helpers.py) and the
2121Qt async path (MainProcess.compile_from_context) delegate to this module.
2222
2323Provides:
24- - `resolve_engine_command` — load an engine and derive (program, args)
25- - `run_engine_compile` — full synchronous compilation pipeline
24+ - `resolve_engine_command` - load an engine and derive (program, args)
25+ - `run_engine_compile` - full synchronous compilation pipeline
2626"""
2727
2828from __future__ import annotations
@@ -178,16 +178,16 @@ def run_engine_compile_streaming(
178178 Returns:
179179 A result dict.
180180 """
181- # ── 1. Validate entry point ──────────────────────────────────────────────
181+ # -- 1. Validate entry point ----------------------------------------------
182182 entry_path = workspace / Path (context .entry_point )
183183 if not context .entry_point or not entry_path .is_file ():
184184 return _failure (f"Entrypoint missing or obsolete: { context .entry_point } " )
185185
186- # ── 2. Resolve (program, args, env) from engine ──────────────────────────
186+ # -- 2. Resolve (program, args, env) from engine --------------------------
187187 try :
188188 if on_stdout :
189189 on_stdout (
190- "🔨 Étape 1/3 : Vérification et installation des outils requis..."
190+ "Etape 1/3 : Verification et installation des outils requis..."
191191 )
192192
193193 import Core .engine as engines_loader
@@ -197,57 +197,90 @@ def run_engine_compile_streaming(
197197 # Ensure tools are installed (this may take time, so we do it in the thread)
198198 def _log (fr , en ):
199199 if on_stdout :
200- on_stdout (f" ➡️ { en } " )
200+ on_stdout (f" -> { en } " )
201201
202202 # We pass a dummy 'gui' object that supports log_i18n_level-like logging
203203 class LogBridge :
204- def __init__ (self , log_cb ):
204+ def __init__ (self , log_cb , workspace_path : Path ):
205205 self .log_cb = log_cb
206+ self .workspace_dir = str (workspace_path )
207+ self .log = self # So gui.log.append works
208+ self .use_system_python = False # Default for CLI
209+ self .venv_path_manuel = None
210+ self ._venv_manager = None
211+ self ._sys_deps_manager = None
212+
213+ def append (self , message : str ):
214+ # message is already formatted by log_i18n_level
215+ self .log_cb ("" , message )
206216
207217 def tr (self , fr , en ):
208218 return en # Simple fallback
209219
220+ @property
221+ def venv_manager (self ):
222+ if self ._venv_manager is None :
223+ from Core .Venv_Manager .Manager import VenvManager
224+
225+ self ._venv_manager = VenvManager (self )
226+ return self ._venv_manager
227+
228+ @property
229+ def sys_deps_manager (self ):
230+ if self ._sys_deps_manager is None :
231+ from Core .SysDependencyManager import SysDependencyManager
232+
233+ self ._sys_deps_manager = SysDependencyManager (self )
234+ return self ._sys_deps_manager
235+
236+ bridge = LogBridge (_log , workspace )
237+ # Link bridge to engine for venv/tool resolution in build_command
238+ try :
239+ engine_instance ._gui = bridge
240+ except Exception :
241+ pass
242+
210243 if hasattr (engine_instance , "ensure_tools_installed" ):
211244 if not engine_instance .ensure_tools_installed (
212- LogBridge ( _log ) , stop_signal = stop_signal
245+ bridge , stop_signal = stop_signal
213246 ):
214247 if stop_signal and stop_signal ():
215- return _failure ("Compilation annulée par l'utilisateur." )
248+ return _failure ("Compilation annulee par l'utilisateur." )
216249 return _failure (
217- f"Échec de l'installation des outils pour '{ engine_id } '"
250+ f"Echec de l'installation des outils pour '{ engine_id } '"
218251 )
219252
220253 if stop_signal and stop_signal ():
221- return _failure ("Compilation annulée ." )
254+ return _failure ("Compilation annulee ." )
222255
223256 if on_stdout :
224- on_stdout ("⚙️ Étape 2/3 : Génération de la commande de compilation..." )
257+ on_stdout ("Etape 2/3 : Generation de la commande de compilation..." )
225258
226259 program , args , engine_env = resolve_engine_command (
227260 engine_id , context , engine_config
228261 )
229262 except EngineRunnerError as exc :
230263 return _failure (str (exc ))
231264 except Exception as exc :
232- return _failure (f"Échec de la préparation de l'engine '{ engine_id } ': { exc } " )
265+ return _failure (f"Echec de la preparation de l'engine '{ engine_id } ': { exc } " )
233266
234267 if stop_signal and stop_signal ():
235- return _failure ("Compilation annulée ." )
268+ return _failure ("Compilation annulee ." )
236269
237- # ── 3. Security hardening ────────────────────────────────────────────────
270+ # -- 3. Security hardening ------------------------------------------------
238271 try :
239272 full_env = dict (engine_env )
240273 full_env ["ARK_WORKSPACE" ] = str (workspace )
241274 safe_program , safe_args , safe_env = secure_command (program , args , full_env )
242275 except Exception as exc :
243- return _failure (f"Commande de compilation non sécurisée bloquée : { exc } " )
276+ return _failure (f"Commande de compilation non securisee bloquee : { exc } " )
244277
245- # ── 4. Run with streaming ────────────────────────────────────────────────
278+ # -- 4. Run with streaming ------------------------------------------------
246279 command = [safe_program ] + safe_args
247280
248281 if on_stdout :
249- on_stdout (f"🚀 Étape 3/3 : Exécution du processus de compilation..." )
250- on_stdout (f" 💻 Commande : { ' ' .join (command )} " )
282+ on_stdout (f"Etape 3/3 : Execution du processus de compilation..." )
283+ on_stdout (f" Commande : { ' ' .join (command )} " )
251284 on_stdout ("-" * 40 )
252285
253286 try :
@@ -307,7 +340,7 @@ def _read_stream(stream, callback):
307340 }
308341
309342
310- # ── helpers ──────────────────────────────────────────────────────────────────
343+ # -- helpers ------------------------------------------------------------------
311344
312345
313346def _failure (error : str ) -> dict [str , Any ]:
0 commit comments