Skip to content

Commit 1942e61

Browse files
committed
correction des engines
1 parent 32dd161 commit 1942e61

3 files changed

Lines changed: 230 additions & 131 deletions

File tree

Core/Compiler/mainprocess.py

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -906,134 +906,6 @@ def cancel_all_compilations(self):
906906
)
907907

908908

909-
def build_pyinstaller_command(self, file):
910-
cmd = ["pyinstaller"]
911-
if self.opt_onefile.isChecked():
912-
cmd.append("--onefile")
913-
if self.opt_windowed.isChecked():
914-
cmd.append("--windowed")
915-
if self.opt_noconfirm.isChecked():
916-
cmd.append("--noconfirm")
917-
if self.opt_clean.isChecked():
918-
cmd.append("--clean")
919-
if self.opt_noupx.isChecked():
920-
cmd.append("--noupx")
921-
if self.opt_debug.isChecked():
922-
cmd.append("--debug")
923-
if self.icon_path:
924-
cmd.append(f"--icon={self.icon_path}")
925-
# Ajout des fichiers/dossiers de données PyInstaller
926-
if hasattr(self, "pyinstaller_data"):
927-
for src, dest in self.pyinstaller_data:
928-
cmd.append(f"--add-data={src}:{dest}")
929-
# Auto ajout des hooks/plugins via détection
930-
try:
931-
auto_map = compute_for_all(self) or {}
932-
auto_args = auto_map.get("pyinstaller", [])
933-
if auto_args:
934-
cmd.extend(auto_args)
935-
except Exception as e:
936-
try:
937-
self.log.append(f"⚠️ Auto-détection PyInstaller: {e}")
938-
except Exception:
939-
pass
940-
cmd.append(file)
941-
942-
custom_name = self.output_name_input.text().strip()
943-
if custom_name:
944-
output_name = (
945-
custom_name + ".exe" if platform.system() == "Windows" else custom_name
946-
)
947-
else:
948-
base_name = os.path.splitext(os.path.basename(file))[0]
949-
output_name = (
950-
base_name + ".exe" if platform.system() == "Windows" else base_name
951-
)
952-
cmd += ["--name", output_name]
953-
954-
# Dossier de sortie
955-
output_dir = self.output_dir_input.text().strip()
956-
if output_dir:
957-
cmd += ["--distpath", output_dir]
958909

959-
return cmd
960910

961911

962-
def build_nuitka_command(self, file):
963-
cmd = ["python3", "-m", "nuitka"]
964-
if self.nuitka_onefile and self.nuitka_onefile.isChecked():
965-
cmd.append("--onefile")
966-
if self.nuitka_standalone and self.nuitka_standalone.isChecked():
967-
cmd.append("--standalone")
968-
import platform
969-
970-
if (
971-
self.nuitka_disable_console
972-
and self.nuitka_disable_console.isChecked()
973-
and platform.system() == "Windows"
974-
):
975-
cmd.append("--windows-disable-console")
976-
if self.nuitka_show_progress and self.nuitka_show_progress.isChecked():
977-
cmd.append("--show-progress")
978-
# Ajout automatique du plugin PySide6 ou PyQt6 si utilisé, mais jamais les deux
979-
plugins = []
980-
# Champ nuitka_plugins supprimé: les plugins sont gérés automatiquement
981-
# Forcer l'ajout de pyside6 ou pyqt6 si importés dans le projet
982-
found_pyside6 = False
983-
found_pyqt6 = False
984-
try:
985-
with open(file, encoding="utf-8") as f:
986-
content = f.read()
987-
if "import PySide6" in content or "from PySide6" in content:
988-
found_pyside6 = True
989-
if "import PyQt6" in content or "from PyQt6" in content:
990-
found_pyqt6 = True
991-
except Exception:
992-
pass
993-
# Ne jamais activer les deux plugins Qt en même temps
994-
if found_pyside6:
995-
if "pyqt6" in plugins:
996-
plugins.remove("pyqt6")
997-
if "pyside6" not in plugins:
998-
plugins.append("pyside6")
999-
elif found_pyqt6:
1000-
if "pyside6" in plugins:
1001-
plugins.remove("pyside6")
1002-
if "pyqt6" not in plugins:
1003-
plugins.append("pyqt6")
1004-
# Si les deux sont dans la liste, n'en garder qu'un (priorité à pyside6)
1005-
if "pyside6" in plugins and "pyqt6" in plugins:
1006-
plugins.remove("pyqt6")
1007-
for plugin in plugins:
1008-
cmd.append(f"--plugin-enable={plugin}")
1009-
# Auto ajout des plugins Nuitka via détection
1010-
try:
1011-
auto_map = compute_for_all(self) or {}
1012-
auto_nuitka_args = auto_map.get("nuitka", [])
1013-
for a in auto_nuitka_args:
1014-
if a not in cmd:
1015-
cmd.append(a)
1016-
except Exception as e:
1017-
try:
1018-
self.log.append(f"⚠️ Auto-détection Nuitka: {e}")
1019-
except Exception:
1020-
pass
1021-
# Nuitka icon: priorité à self.nuitka_icon_path si défini, sinon self.icon_path
1022-
import platform
1023-
1024-
if platform.system() == "Windows":
1025-
if hasattr(self, "nuitka_icon_path") and self.nuitka_icon_path:
1026-
cmd.append(f"--windows-icon-from-ico={self.nuitka_icon_path}")
1027-
elif self.icon_path:
1028-
cmd.append(f"--windows-icon-from-ico={self.icon_path}")
1029-
if self.nuitka_output_dir and self.nuitka_output_dir.text().strip():
1030-
cmd.append(f"--output-dir={self.nuitka_output_dir.text().strip()}")
1031-
# Ajout des fichiers de données Nuitka
1032-
if hasattr(self, "nuitka_data_files"):
1033-
for src, dest in self.nuitka_data_files:
1034-
cmd.append(f"--include-data-files={src}={dest}")
1035-
if hasattr(self, "nuitka_data_dirs"):
1036-
for src, dest in self.nuitka_data_dirs:
1037-
cmd.append(f"--include-data-dir={src}={dest}")
1038-
cmd.append(file)
1039-
return cmd

ENGINES/nuitka/engine.py

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,131 @@ def _on_check(ok: bool):
379379
return True
380380

381381
def build_command(self, gui, file: str) -> list[str]:
382-
return gui.build_nuitka_command(file)
382+
import sys
383+
cmd = [sys.executable, "-m", "nuitka"]
384+
385+
# Options checkboxes
386+
try:
387+
if hasattr(self, "_nuitka_onefile") and self._nuitka_onefile.isChecked():
388+
cmd.append("--onefile")
389+
except Exception:
390+
pass
391+
392+
try:
393+
if hasattr(self, "_nuitka_standalone") and self._nuitka_standalone.isChecked():
394+
cmd.append("--standalone")
395+
except Exception:
396+
pass
397+
398+
try:
399+
if (
400+
hasattr(self, "_nuitka_disable_console")
401+
and self._nuitka_disable_console.isChecked()
402+
and platform.system() == "Windows"
403+
):
404+
cmd.append("--windows-disable-console")
405+
except Exception:
406+
pass
407+
408+
try:
409+
if hasattr(self, "_nuitka_show_progress") and self._nuitka_show_progress.isChecked():
410+
cmd.append("--show-progress")
411+
except Exception:
412+
pass
413+
414+
# Auto-detect Qt plugins (PySide6 or PyQt6, but not both)
415+
plugins = []
416+
found_pyside6 = False
417+
found_pyqt6 = False
418+
419+
try:
420+
with open(file, encoding="utf-8") as f:
421+
content = f.read()
422+
if "import PySide6" in content or "from PySide6" in content:
423+
found_pyside6 = True
424+
if "import PyQt6" in content or "from PyQt6" in content:
425+
found_pyqt6 = True
426+
except Exception:
427+
pass
428+
429+
# Never enable both Qt plugins at the same time
430+
if found_pyside6:
431+
if "pyqt6" in plugins:
432+
plugins.remove("pyqt6")
433+
if "pyside6" not in plugins:
434+
plugins.append("pyside6")
435+
elif found_pyqt6:
436+
if "pyside6" in plugins:
437+
plugins.remove("pyside6")
438+
if "pyqt6" not in plugins:
439+
plugins.append("pyqt6")
440+
441+
# If both are in the list, keep only one (priority to pyside6)
442+
if "pyside6" in plugins and "pyqt6" in plugins:
443+
plugins.remove("pyqt6")
444+
445+
for plugin in plugins:
446+
cmd.append(f"--plugin-enable={plugin}")
447+
448+
# Auto-detection of plugins/hooks
449+
try:
450+
from engine_sdk.auto_build_command import compute_auto_for_engine
451+
auto_args = compute_auto_for_engine(gui, "nuitka") or []
452+
for arg in auto_args:
453+
if arg not in cmd:
454+
cmd.append(arg)
455+
except Exception as e:
456+
try:
457+
gui.log.append(gui.tr(
458+
f"⚠️ Auto-détection Nuitka: {e}",
459+
f"⚠️ Nuitka auto-detection: {e}"
460+
))
461+
except Exception:
462+
pass
463+
464+
# Icon (Windows only)
465+
try:
466+
if platform.system() == "Windows":
467+
icon_path = None
468+
if hasattr(self, "_nuitka_icon_path") and self._nuitka_icon_path:
469+
icon_path = self._nuitka_icon_path
470+
elif hasattr(self, "_icon_path") and self._icon_path:
471+
icon_path = self._icon_path
472+
473+
if icon_path:
474+
cmd.append(f"--windows-icon-from-ico={icon_path}")
475+
except Exception:
476+
pass
477+
478+
# Output directory
479+
try:
480+
if hasattr(self, "_nuitka_output_dir") and self._nuitka_output_dir:
481+
output_dir = self._nuitka_output_dir.text().strip()
482+
if output_dir:
483+
cmd.append(f"--output-dir={output_dir}")
484+
except Exception:
485+
pass
486+
487+
# Data files
488+
try:
489+
if hasattr(self, "_nuitka_data_files"):
490+
for src, dest in self._nuitka_data_files:
491+
cmd.append(f"--include-data-files={src}={dest}")
492+
except Exception:
493+
pass
494+
495+
# Data directories
496+
try:
497+
if hasattr(self, "_nuitka_data_dirs"):
498+
for src, dest in self._nuitka_data_dirs:
499+
cmd.append(f"--include-data-dir={src}={dest}")
500+
except Exception:
501+
pass
502+
503+
# Script file
504+
cmd.append(file)
505+
506+
return cmd
383507

384508
def program_and_args(self, gui, file: str) -> Optional[tuple[str, list[str]]]:
385509
# Nuitka s'exécute avec python -m nuitka dans le venv; resolve via VenvManager

ENGINES/pyinstaller/engine.py

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,111 @@ def _on_check(ok: bool):
255255
return True
256256

257257
def build_command(self, gui, file: str) -> list[str]:
258-
# Reuse existing logic from gui (compiler.py build_pyinstaller_command)
259-
return gui.build_pyinstaller_command(file)
258+
import sys
259+
260+
cmd = [sys.executable, "-m", "pyinstaller"]
261+
262+
# Options checkboxes
263+
try:
264+
if hasattr(self, "_opt_onefile") and self._opt_onefile.isChecked():
265+
cmd.append("--onefile")
266+
except Exception:
267+
pass
268+
269+
try:
270+
if hasattr(self, "_opt_windowed") and self._opt_windowed.isChecked():
271+
cmd.append("--windowed")
272+
except Exception:
273+
pass
274+
275+
try:
276+
if hasattr(self, "_opt_noconfirm") and self._opt_noconfirm.isChecked():
277+
cmd.append("--noconfirm")
278+
except Exception:
279+
pass
280+
281+
try:
282+
if hasattr(self, "_opt_clean") and self._opt_clean.isChecked():
283+
cmd.append("--clean")
284+
except Exception:
285+
pass
286+
287+
try:
288+
if hasattr(self, "_opt_noupx") and self._opt_noupx.isChecked():
289+
cmd.append("--noupx")
290+
except Exception:
291+
pass
292+
293+
try:
294+
if hasattr(self, "_opt_debug") and self._opt_debug.isChecked():
295+
cmd.append("--debug")
296+
except Exception:
297+
pass
298+
299+
# Icon
300+
try:
301+
if hasattr(self, "_icon_path") and self._icon_path:
302+
cmd.append(f"--icon={self._icon_path}")
303+
except Exception:
304+
pass
305+
306+
# Data files
307+
try:
308+
if hasattr(self, "_pyinstaller_data"):
309+
for src, dest in self._pyinstaller_data:
310+
cmd.append(f"--add-data={src}:{dest}")
311+
except Exception:
312+
pass
313+
314+
# Auto-detection of plugins/hooks
315+
try:
316+
from engine_sdk.auto_build_command import compute_auto_for_engine
317+
auto_args = compute_auto_for_engine(gui, "pyinstaller") or []
318+
if auto_args:
319+
cmd.extend(auto_args)
320+
except Exception as e:
321+
try:
322+
gui.log.append(gui.tr(
323+
f"⚠️ Auto-détection PyInstaller: {e}",
324+
f"⚠️ PyInstaller auto-detection: {e}"
325+
))
326+
except Exception:
327+
pass
328+
329+
# Output name
330+
try:
331+
custom_name = ""
332+
if hasattr(self, "_output_name_input") and self._output_name_input:
333+
custom_name = self._output_name_input.text().strip()
334+
335+
if custom_name:
336+
output_name = (
337+
custom_name + ".exe" if platform.system() == "Windows" else custom_name
338+
)
339+
else:
340+
base_name = os.path.splitext(os.path.basename(file))[0]
341+
output_name = (
342+
base_name + ".exe" if platform.system() == "Windows" else base_name
343+
)
344+
cmd.extend(["--name", output_name])
345+
except Exception:
346+
pass
347+
348+
# Output directory
349+
try:
350+
output_dir = ""
351+
if hasattr(self, "_output_dir_input") and self._output_dir_input:
352+
output_dir = self._output_dir_input.text().strip()
353+
354+
if output_dir:
355+
cmd.extend(["--distpath", output_dir])
356+
except Exception:
357+
pass
358+
359+
# Script file
360+
cmd.append(file)
361+
362+
return cmd
260363

261364
def program_and_args(self, gui, file: str) -> Optional[tuple[str, list[str]]]:
262365
cmd = self.build_command(gui, file)

0 commit comments

Comments
 (0)