@@ -484,7 +484,24 @@ def ensure_tools_installed(self, venv_root: str, tools: list[str]) -> None:
484484 f"Verification de { tools [0 ]} ..." ,
485485 )
486486 self ._call_ui ("update_progress_progress" , "tools_check" , 0 , len (tools ))
487+
488+ # In CLI mode without a global event loop, we might need a local one
489+ is_cli = getattr (self .parent , "verbose" , False ) or os .environ .get ("PYCOMPILER_CLI" ) == "1"
490+ loop = None
491+ if is_cli :
492+ from PySide6 .QtCore import QCoreApplication , QEventLoop
493+ if not QCoreApplication .instance ():
494+ self ._app_ref = QCoreApplication ([]) # Keep alive
495+
496+ loop = QEventLoop ()
497+ # We need a way to stop the loop when all tools are checked
498+ self ._venv_check_loop = loop
499+
487500 self ._check_next_venv_pkg ()
501+
502+ if loop :
503+ loop .exec ()
504+ self ._venv_check_loop = None
488505 except Exception as e :
489506 self ._safe_log (
490507 f"[ERROR] { self ._tools_stage_prefix ()} Erreur ensure_tools_installed: { e } "
@@ -530,7 +547,23 @@ def ensure_tools_installed_system(self, tools: list[str]) -> None:
530547 f"Verification de { tools [0 ]} ..." ,
531548 )
532549 self ._call_ui ("update_progress_progress" , "tools_check" , 0 , len (tools ))
550+
551+ # In CLI mode without a global event loop, we might need a local one
552+ is_cli = getattr (self .parent , "verbose" , False ) or os .environ .get ("PYCOMPILER_CLI" ) == "1"
553+ loop = None
554+ if is_cli :
555+ from PySide6 .QtCore import QCoreApplication , QEventLoop
556+ if not QCoreApplication .instance ():
557+ self ._app_ref = QCoreApplication ([]) # Keep alive
558+
559+ loop = QEventLoop ()
560+ self ._venv_check_loop = loop
561+
533562 self ._check_next_venv_pkg ()
563+
564+ if loop :
565+ loop .exec ()
566+ self ._venv_check_loop = None
534567 except Exception as e :
535568 self ._safe_log (
536569 f"[ERROR] { self ._tools_stage_prefix ()} Erreur ensure_tools_installed_system: { e } "
@@ -918,6 +951,10 @@ def _check_next_venv_pkg(self):
918951 """Execute _check_next_venv_pkg logic for this component."""
919952 if self ._is_cancel_requested ():
920953 self ._call_ui ("close_progress" , "tools_check" )
954+ # Exit local loop if any
955+ loop = getattr (self , "_venv_check_loop" , None )
956+ if loop :
957+ loop .quit ()
921958 return
922959 if self ._venv_check_index >= len (self ._venv_check_pkgs ):
923960 self ._call_ui (
@@ -931,6 +968,11 @@ def _check_next_venv_pkg(self):
931968 self ._call_ui ("update_progress_progress" , "tools_check" , total , total )
932969 self ._call_ui ("close_progress" , "tools_check" )
933970
971+ # Exit local loop if any
972+ loop = getattr (self , "_venv_check_loop" , None )
973+ if loop :
974+ loop .quit ()
975+
934976 # Installer les dependances du projet si un requirements.txt est present
935977 try :
936978 if getattr (self .parent , "workspace_dir" , None ):
@@ -996,6 +1038,11 @@ def _on_venv_pkg_checked(self, process, code, status, pkg):
9961038 level = "error" ,
9971039 )
9981040 self ._call_ui ("close_progress" , "tools_check" )
1041+
1042+ # Exit local loop if any
1043+ loop = getattr (self , "_venv_check_loop" , None )
1044+ if loop :
1045+ loop .quit ()
9991046 return
10001047
10011048 self ._safe_log (
@@ -1048,7 +1095,14 @@ def _on_venv_check_output(self, process, error=False):
10481095 lines = data .strip ().splitlines ()
10491096 if lines :
10501097 self ._call_ui ("update_progress_message" , "tools_check" , lines [- 1 ][:200 ])
1051- self ._safe_log (data )
1098+
1099+ # Detailed logging for verbose mode or errors
1100+ is_verbose = getattr (self .parent , "verbose" , False )
1101+ if is_verbose or error :
1102+ for line in lines :
1103+ lvl = "warning" if error else "info"
1104+ # We use a slight indentation to make it clear it's sub-output
1105+ self ._safe_log (f" [pip] { line } " , level = lvl )
10521106
10531107 def verify_venv_binding (self , venv_root : str ) -> bool :
10541108 """Keep synchronous verification path for internal compatibility."""
@@ -1479,7 +1533,13 @@ def _on_venv_output(self, process, error=False):
14791533 self ._venv_progress_lines ,
14801534 0 ,
14811535 )
1482- self ._safe_log (data )
1536+
1537+ # Detailed logging for verbose mode or errors
1538+ is_verbose = getattr (self .parent , "verbose" , False )
1539+ if is_verbose or error :
1540+ for line in lines :
1541+ lvl = "warning" if error else "info"
1542+ self ._safe_log (f" [venv] { line } " , level = lvl )
14831543
14841544 def _on_venv_created (self , process , code , status , venv_path ):
14851545 """Handle the related event callback."""
@@ -1735,7 +1795,13 @@ def _on_pip_output(self, process, error=False):
17351795 self ._call_ui (
17361796 "update_progress_progress" , "reqs_install" , self ._pip_progress_lines , 0
17371797 )
1738- self ._safe_log (data )
1798+
1799+ # Detailed logging for verbose mode or errors
1800+ is_verbose = getattr (self .parent , "verbose" , False )
1801+ if is_verbose or error :
1802+ for line in lines :
1803+ lvl = "warning" if error else "info"
1804+ self ._safe_log (f" [pip] { line } " , level = lvl )
17391805
17401806 def _on_pip_finished (self , process , code , status ):
17411807 """Handle the related event callback."""
0 commit comments