3131from engine_sdk import engine_register
3232
3333
34-
3534@engine_register
3635class CXFreezeEngine (CompilerEngine ):
3736 """
3837 CX_Freeze compilation engine.
39-
38+
4039 Features:
4140 - Onefile and onedir modes
4241 - Windowed/console mode selection
@@ -61,16 +60,16 @@ def preflight(self, gui, file: str) -> bool:
6160 venv_manager = getattr (gui , "venv_manager" , None )
6261 if not venv_manager :
6362 return True # Let build_command fail instead
64-
63+
6564 venv_path = venv_manager .resolve_project_venv ()
6665 if not venv_path :
6766 return True # Let build_command fail instead
68-
67+
6968 if not venv_manager .has_tool_binary (venv_path , "cx_freeze" ):
7069 # Try to install cx_freeze
7170 venv_manager .ensure_tools_installed (venv_path , ["cx_freeze" ])
7271 return False # Will be retried after installation
73-
72+
7473 return True
7574 except Exception :
7675 return True # Let build_command handle errors
@@ -79,7 +78,7 @@ def build_command(self, gui, file: str) -> list[str]:
7978 """Build the CX_Freeze command line."""
8079 try :
8180 venv_manager = getattr (gui , "venv_manager" , None )
82-
81+
8382 # Resolve venv python
8483 if venv_manager :
8584 venv_path = venv_manager .resolve_project_venv ()
@@ -89,13 +88,12 @@ def build_command(self, gui, file: str) -> list[str]:
8988 python_path = sys .executable
9089 else :
9190 python_path = sys .executable
92-
91+
9392 # Start with python -m cx_Freeze
9493 cmd = [python_path , "-m" , "cx_Freeze" ]
95-
96-
94+
9795 return cmd
98-
96+
9997 except Exception as e :
10098 try :
10199 if hasattr (gui , "log" ):
@@ -115,16 +113,16 @@ def environment(self, gui, file: str) -> Optional[dict[str, str]]:
115113 """Return environment variables for the compilation process."""
116114 try :
117115 env = {}
118-
116+
119117 # Set PYTHONIOENCODING for proper output handling
120118 env ["PYTHONIOENCODING" ] = "utf-8"
121-
119+
122120 # Disable PYTHONUTF8 mode to avoid conflicts
123121 env ["PYTHONUTF8" ] = "0"
124-
122+
125123 # Set LC_ALL for consistent output
126124 env ["LC_ALL" ] = "C"
127-
125+
128126 return env if env else None
129127 except Exception :
130128 return None
@@ -137,7 +135,9 @@ def on_success(self, gui, file: str) -> None:
137135 if output_dir and output_dir .text ().strip ():
138136 try :
139137 if hasattr (gui , "log" ):
140- gui .log .append (f"📁 Compilation CX_Freeze terminée. Sortie dans: { output_dir .text ().strip ()} \n " )
138+ gui .log .append (
139+ f"📁 Compilation CX_Freeze terminée. Sortie dans: { output_dir .text ().strip ()} \n "
140+ )
141141 except Exception :
142142 pass
143143 except Exception :
@@ -195,9 +195,7 @@ def create_tab(self, gui):
195195 output_layout = QHBoxLayout ()
196196 self ._cx_output_dir = QLineEdit ()
197197 self ._cx_output_dir .setObjectName ("cx_output_dir_dynamic" )
198- self ._cx_output_dir .setPlaceholderText (
199- "Dossier de sortie"
200- )
198+ self ._cx_output_dir .setPlaceholderText ("Dossier de sortie" )
201199 output_layout .addWidget (self ._cx_output_dir )
202200 layout .addLayout (output_layout )
203201
@@ -247,7 +245,9 @@ def _get_input(self, name: str):
247245 def get_log_prefix (self , file_basename : str ) -> str :
248246 return f"CX_Freeze ({ self .version } )"
249247
250- def should_compile_file (self , gui , file : str , selected_files : list [str ], python_files : list [str ]) -> bool :
248+ def should_compile_file (
249+ self , gui , file : str , selected_files : list [str ], python_files : list [str ]
250+ ) -> bool :
251251 """Determine if a file should be included in the compilation queue."""
252252 # Skip non-Python files
253253 if not file .endswith (".py" ):
@@ -258,13 +258,13 @@ def apply_i18n(self, gui, tr: dict) -> None:
258258 """Apply internationalization translations to the engine UI."""
259259 try :
260260 from Core .engines_loader .registry import resolve_language_code
261-
261+
262262 # Resolve language code
263263 code = resolve_language_code (gui , tr )
264-
264+
265265 # Load engine-local translations
266266 lang_data = self ._load_language_file (code )
267-
267+
268268 # Apply translations to UI elements if they exist
269269 if hasattr (self , "_cx_onefile" ) and "onefile_checkbox" in lang_data :
270270 self ._cx_onefile .setText (lang_data ["onefile_checkbox" ])
@@ -282,10 +282,10 @@ def _load_language_file(self, code: str) -> dict:
282282 try :
283283 import importlib .resources as ilr
284284 import json
285-
285+
286286 pkg = __package__
287287 lang_data = {}
288-
288+
289289 # Try exact code first
290290 try :
291291 with ilr .as_file (
@@ -297,7 +297,7 @@ def _load_language_file(self, code: str) -> dict:
297297 return lang_data
298298 except Exception :
299299 pass
300-
300+
301301 # Fallback to base language (e.g., "fr" from "fr-CA")
302302 if "-" in code :
303303 base = code .split ("-" , 1 )[0 ]
@@ -311,19 +311,16 @@ def _load_language_file(self, code: str) -> dict:
311311 return lang_data
312312 except Exception :
313313 pass
314-
314+
315315 # Final fallback to English
316316 try :
317- with ilr .as_file (
318- ilr .files (pkg ).joinpath ("languages" , "en.json" )
319- ) as p :
317+ with ilr .as_file (ilr .files (pkg ).joinpath ("languages" , "en.json" )) as p :
320318 if os .path .isfile (str (p )):
321319 with open (str (p ), encoding = "utf-8" ) as f :
322320 lang_data = json .load (f ) or {}
323321 except Exception :
324322 pass
325-
323+
326324 return lang_data
327325 except Exception :
328326 return {}
329-
0 commit comments