@@ -72,28 +72,37 @@ def preflight(self, gui, file: str) -> bool:
7272 """Preflight check - dependencies are handled automatically by required_tools."""
7373 return True
7474
75- def build_command_from_context (self , context : BuildContext ) -> list [str ]:
75+ def build_command (self , context : BuildContext ) -> list [str ]:
7676 """Build a Nuitka command line from a normalized build context."""
7777 cfg = getattr (self , "_config_overrides" , {})
7878 if not isinstance (cfg , dict ):
7979 cfg = {}
8080
81- cmd = [sys .executable , "-m" , "nuitka" ]
81+ # Resolve executable (prefer venv if available)
82+ python_exe = sys .executable
83+ if hasattr (self , "_gui" ) and self ._gui :
84+ venv_manager = getattr (self ._gui , "venv_manager" , None )
85+ if venv_manager :
86+ venv_path = venv_manager .resolve_project_venv ()
87+ if venv_path :
88+ python_exe = venv_manager .python_path (venv_path )
89+
90+ cmd = [python_exe , "-m" , "nuitka" ]
8291
8392 standalone_enabled = bool (cfg .get ("standalone" , False ))
84- if hasattr (self , "_nuitka_standalone" ):
93+ if hasattr (self , "_nuitka_standalone" ) and self . _nuitka_standalone is not None :
8594 standalone_enabled = bool (self ._nuitka_standalone .isChecked ())
8695 if standalone_enabled :
8796 cmd .append ("--standalone" )
8897
8998 onefile_enabled = bool (cfg .get ("onefile" , False ))
90- if hasattr (self , "_nuitka_onefile" ):
99+ if hasattr (self , "_nuitka_onefile" ) and self . _nuitka_onefile is not None :
91100 onefile_enabled = bool (self ._nuitka_onefile .isChecked ())
92101 if onefile_enabled :
93102 cmd .append ("--onefile" )
94103
95104 disable_console = bool (cfg .get ("disable_console" , False ))
96- if hasattr (self , "_nuitka_disable_console" ):
105+ if hasattr (self , "_nuitka_disable_console" ) and self . _nuitka_disable_console is not None :
97106 disable_console = bool (self ._nuitka_disable_console .isChecked ())
98107 if disable_console :
99108 cmd .append ("--windows-disable-console" )
@@ -107,8 +116,8 @@ def build_command_from_context(self, context: BuildContext) -> list[str]:
107116 cmd .append (f"--output-filename={ output_name } " )
108117
109118 icon_path = str (context .icon or cfg .get ("selected_icon" ) or "" ).strip ()
110- if not icon_path :
111- icon_path = str (getattr ( self , " _nuitka_selected_icon" , "" ) or "" ).strip ()
119+ if not icon_path and hasattr ( self , "_nuitka_selected_icon" ) and self . _nuitka_selected_icon :
120+ icon_path = str (self . _nuitka_selected_icon ).strip ()
112121 if icon_path :
113122 cmd .append (f"--windows-icon-from-ico={ icon_path } " )
114123
@@ -129,98 +138,17 @@ def build_command_from_context(self, context: BuildContext) -> list[str]:
129138 if source and destination :
130139 cmd .append (f"--include-data-dir={ source } ={ destination } " )
131140
132- cmd .append (context .entry_point )
133- return cmd
134-
135- def build_command (self , gui , file : str ) -> list [str ]:
136- """Build the Nuitka command line."""
137- try :
138- cfg = getattr (self , "_config_overrides" , {})
139- if not isinstance (cfg , dict ):
140- cfg = {}
141-
142- venv_manager = getattr (gui , "venv_manager" , None )
143-
144- # Resolve venv python
145- if venv_manager :
146- venv_path = venv_manager .resolve_project_venv ()
147- if venv_path :
148- python_path = venv_manager .python_path (venv_path )
149- else :
150- python_path = sys .executable
151- else :
152- python_path = sys .executable
153-
154- # Start with python -m nuitka
155- cmd = [python_path , "-m" , "nuitka" ]
156-
157- # Standalone mode
158- standalone_enabled = bool (cfg .get ("standalone" , False ))
159- if hasattr (self , "_nuitka_standalone" ):
160- standalone_enabled = bool (self ._nuitka_standalone .isChecked ())
161- if standalone_enabled :
162- cmd .append ("--standalone" )
163-
164- # Onefile mode
165- onefile_enabled = bool (cfg .get ("onefile" , False ))
166- if hasattr (self , "_nuitka_onefile" ):
167- onefile_enabled = bool (self ._nuitka_onefile .isChecked ())
168- if onefile_enabled :
169- cmd .append ("--onefile" )
170-
171- # Windowed (no console)
172- disable_console = bool (cfg .get ("disable_console" , False ))
173- if hasattr (self , "_nuitka_disable_console" ):
174- disable_console = bool (self ._nuitka_disable_console .isChecked ())
175- if disable_console :
176- cmd .append ("--windows-disable-console" )
177-
178- # Output directory
179- output_dir_value = str (cfg .get ("output_dir" ) or "" ).strip ()
180- if (
181- hasattr (self , "_nuitka_output_dir" )
182- and self ._nuitka_output_dir .text ().strip ()
183- ):
184- output_dir_value = self ._nuitka_output_dir .text ().strip ()
185- if output_dir_value :
186- cmd .append (f"--output-dir={ output_dir_value } " )
187-
188- # Icon
189- selected_icon = getattr (self , "_nuitka_selected_icon" , None )
190- if not selected_icon :
191- selected_icon = cfg .get ("selected_icon" )
192- if selected_icon :
193- cmd .extend (["--windows-icon" , selected_icon ])
194-
195- # Auto-mapping args (mapping.json / auto builder)
141+ # Auto-mapping args (mapping.json / auto builder)
142+ if hasattr (self , "_gui" ) and self ._gui :
196143 try :
197- auto_args = compute_auto_for_engine (gui , self .id )
144+ auto_args = compute_auto_for_engine (self . _gui , self .id )
198145 if auto_args :
199146 cmd .extend (auto_args )
200147 except Exception :
201148 pass
202149
203- # Add the target file
204- cmd .append (file )
205-
206- return cmd
207-
208- except Exception as e :
209- try :
210- if hasattr (gui , "log" ):
211- log_with_level (
212- gui , "error" , f"Erreur construction commande Nuitka: { e } "
213- )
214- except Exception :
215- pass
216- return []
217-
218- def program_and_args (self , gui , file : str ) -> Optional [tuple [str , list [str ]]]:
219- """Return the program and args for QProcess."""
220- cmd = self .build_command (gui , file )
221- if not cmd :
222- return None
223- return cmd [0 ], cmd [1 :]
150+ cmd .append (context .entry_point )
151+ return cmd
224152
225153 def environment (self ) -> Optional [dict [str , str ]]:
226154 """Return environment variables for the compilation process."""
0 commit comments