Skip to content

Commit da2a381

Browse files
committed
Refactor: alignement complet de tous les moteurs sur le BuildContext (suppression des doublons UI et fallbacks redondants)
1 parent 115d967 commit da2a381

3 files changed

Lines changed: 24 additions & 64 deletions

File tree

engines/cx_freeze/__init__.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ def build_command(self, context: BuildContext) -> list[str]:
8787
if windowed_enabled and platform.system() == "Windows":
8888
cmd.extend(["--base", "Win32GUI"])
8989

90-
output_dir = str(context.output_dir or cfg.get("output_dir") or "").strip()
90+
output_dir = str(context.output_dir or "").strip()
9191
if output_dir:
9292
cmd.extend(["--target-dir", output_dir])
9393

94-
icon_path = str(context.icon or cfg.get("selected_icon") or "").strip()
95-
if not icon_path and hasattr(self, "_selected_icon") and self._selected_icon:
96-
icon_path = str(self._selected_icon).strip()
94+
icon_path = str(context.icon or "").strip()
9795
if icon_path:
9896
cmd.extend(["--icon", icon_path])
9997

@@ -145,22 +143,12 @@ def environment(self) -> Optional[dict[str, str]]:
145143
def on_success(self, gui, file: str) -> None:
146144
"""Handle successful compilation."""
147145
try:
148-
# Log success message with output location
149-
output_dir = (
150-
getattr(self, "_cx_output_dir", getattr(gui, "output_dir_input", None))
151-
if hasattr(self, "_gui")
152-
else getattr(self, "_cx_output_dir", None)
153-
)
154-
if output_dir and output_dir.text().strip():
155-
try:
156-
if hasattr(gui, "log"):
157-
log_with_level(
158-
gui,
159-
"success",
160-
f"Compilation CX_Freeze terminée. Sortie dans: {output_dir.text().strip()}",
161-
)
162-
except Exception:
163-
pass
146+
if hasattr(gui, "log"):
147+
log_with_level(
148+
gui,
149+
"success",
150+
"Compilation CX_Freeze terminée avec succès.",
151+
)
164152
except Exception:
165153
pass
166154

engines/nuitka/__init__.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,15 @@ def build_command(self, context: BuildContext) -> list[str]:
107107
if disable_console:
108108
cmd.append("--windows-disable-console")
109109

110-
output_dir = str(context.output_dir or cfg.get("output_dir") or "").strip()
110+
output_dir = str(context.output_dir or "").strip()
111111
if output_dir:
112112
cmd.append(f"--output-dir={output_dir}")
113113

114114
output_name = str(context.project_name or "").strip()
115115
if output_name:
116116
cmd.append(f"--output-filename={output_name}")
117117

118-
icon_path = str(context.icon or cfg.get("selected_icon") or "").strip()
119-
if (
120-
not icon_path
121-
and hasattr(self, "_nuitka_selected_icon")
122-
and self._nuitka_selected_icon
123-
):
124-
icon_path = str(self._nuitka_selected_icon).strip()
118+
icon_path = str(context.icon or "").strip()
125119
if icon_path:
126120
cmd.append(f"--windows-icon-from-ico={icon_path}")
127121

@@ -172,20 +166,12 @@ def environment(self) -> Optional[dict[str, str]]:
172166
def on_success(self, gui, file: str) -> None:
173167
"""Handle successful compilation."""
174168
try:
175-
# Log success message with output location
176-
if (
177-
hasattr(self, "_nuitka_output_dir")
178-
and self._nuitka_output_dir.text().strip()
179-
):
180-
try:
181-
if hasattr(gui, "log"):
182-
log_with_level(
183-
gui,
184-
"success",
185-
f"Compilation Nuitka terminée. Sortie dans: {self._nuitka_output_dir.text().strip()}",
186-
)
187-
except Exception:
188-
pass
169+
if hasattr(gui, "log"):
170+
log_with_level(
171+
gui,
172+
"success",
173+
"Compilation Nuitka terminée avec succès.",
174+
)
189175
except Exception:
190176
pass
191177

engines/pyinstaller/__init__.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,15 @@ def build_command(self, context: BuildContext) -> list[str]:
9292
if windowed_enabled and platform.system() in {"Windows", "Darwin"}:
9393
cmd.append("--windowed")
9494

95-
output_dir = str(context.output_dir or cfg.get("output_dir") or "").strip()
95+
output_dir = str(context.output_dir or "").strip()
9696
if output_dir:
9797
cmd.extend(["--distpath", output_dir])
9898

99-
icon_path = str(context.icon or cfg.get("selected_icon") or "").strip()
100-
if not icon_path and hasattr(self, "_selected_icon") and self._selected_icon:
101-
icon_path = str(self._selected_icon).strip()
99+
icon_path = str(context.icon or "").strip()
102100
if icon_path:
103101
cmd.extend(["--icon", icon_path])
104102

105-
output_name = str(cfg.get("target_name") or context.project_name or "").strip()
103+
output_name = str(context.project_name or "").strip()
106104
if output_name:
107105
cmd.extend(["--name", output_name])
108106

@@ -150,24 +148,12 @@ def environment(self) -> Optional[dict[str, str]]:
150148
def on_success(self, gui, file: str) -> None:
151149
"""Handle successful compilation."""
152150
try:
153-
# Log success message with output location
154-
output_dir = (
155-
getattr(
156-
self, "_output_dir_input", getattr(gui, "output_dir_input", None)
151+
if hasattr(gui, "log"):
152+
log_with_level(
153+
gui,
154+
"success",
155+
"Compilation PyInstaller terminée avec succès.",
157156
)
158-
if hasattr(self, "_gui")
159-
else getattr(self, "_output_dir_input", None)
160-
)
161-
if output_dir and output_dir.text().strip():
162-
try:
163-
if hasattr(gui, "log"):
164-
log_with_level(
165-
gui,
166-
"success",
167-
f"Sortie générée dans: {output_dir.text().strip()}",
168-
)
169-
except Exception:
170-
pass
171157
except Exception:
172158
pass
173159

0 commit comments

Comments
 (0)