@@ -87,12 +87,59 @@ def should_compile_file(
8787 return True
8888
8989 @property
90- def required_tools (self ) -> list [str ]:
90+ def required_tools (self ) -> dict [ str , list [str ] ]:
9191 """
92- Return list of tool names required by this engine (e.g., ['pyinstaller'], ['nuitka']).
93- Used by VenvManager to check/install dependencies.
92+ Return dict of required tools with installation modes.
93+ Keys: 'python' for pip-installable tools, 'system' for system packages.
94+ Used by VenvManager for Python tools and system installer for system tools.
95+ Example: {'python': ['pyinstaller'], 'system': ['build-essential']}
9496 """
95- return []
97+ return {'python' : [], 'system' : []}
98+
99+ def ensure_tools_installed (self , gui ) -> bool :
100+ """
101+ Ensure all required tools are installed.
102+ Returns True if all tools are ready, False if installation failed or was cancelled.
103+ Handles both Python (pip) and system packages.
104+ """
105+ try :
106+ tools = self .required_tools
107+ python_tools = tools .get ('python' , [])
108+ system_tools = tools .get ('system' , [])
109+
110+ # Check if VenvManager is available
111+ if hasattr (gui , 'venv_manager' ) and gui .venv_manager :
112+ venv_root = gui .venv_manager .resolve_project_venv ()
113+ if venv_root :
114+ # Install Python tools via VenvManager
115+ if python_tools :
116+ try :
117+ gui .venv_manager .ensure_tools_installed (venv_root , python_tools )
118+ # Wait for completion (simplified - in practice would need async handling)
119+ except Exception as e :
120+ if hasattr (gui , 'log' ) and gui .log :
121+ gui .log .append (f"⚠️ Failed to install Python tools { python_tools } : { e } " )
122+ return False
123+
124+ # Install system tools
125+ if system_tools :
126+ try :
127+ from Core .sys_deps import install_system_packages
128+ success = install_system_packages (system_tools , gui )
129+ if not success :
130+ if hasattr (gui , 'log' ) and gui .log :
131+ gui .log .append (f"⚠️ Failed to install system tools { system_tools } " )
132+ return False
133+ except Exception as e :
134+ if hasattr (gui , 'log' ) and gui .log :
135+ gui .log .append (f"⚠️ Failed to install system tools { system_tools } : { e } " )
136+ return False
137+
138+ return True
139+ except Exception as e :
140+ if hasattr (gui , 'log' ) and gui .log :
141+ gui .log .append (f"⚠️ Error ensuring tools installed: { e } " )
142+ return False
96143
97144 def get_log_prefix (self , file_basename : str ) -> str :
98145 """
0 commit comments