Skip to content

Commit 015364e

Browse files
committed
Multiple file changes across various modules
1 parent 55207e9 commit 015364e

22 files changed

Lines changed: 463 additions & 394 deletions

Core/Compiler/mainprocess.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,3 @@ def cancel_all_compilations(self):
904904
self.log.append(
905905
"⛔ Toutes les compilations ont été annulées et tous les processus enfants tués.\n"
906906
)
907-
908-
909-
910-
911-

Core/Compiler/process_killer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
1617
def _kill_process_tree(pid: int, *, timeout: float = 5.0, log=None) -> bool:
1718
def _log(msg: str):
1819
try:

Core/MainWindow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,6 @@ def select_icon(self):
10431043
except Exception:
10441044
pass
10451045

1046-
10471046
def select_nuitka_icon(self):
10481047
import platform
10491048

Core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def add(t: str, p: str | None) -> None:
104104
"try_install_missing_modules": (".compiler", "try_install_missing_modules"),
105105
"show_error_dialog": (".compiler", "show_error_dialog"),
106106
"cancel_all_compilations": (".compiler", "cancel_all_compilations"),
107-
108107
# Dependency analysis (some internal helpers intentionally exported)
109108
"suggest_missing_dependencies": (
110109
".dependency_analysis",
@@ -268,7 +267,6 @@ def __getattr__(name: str) -> Any:
268267
),
269268
"show_error_dialog": _load_export("show_error_dialog"),
270269
"cancel_all_compilations": _load_export("cancel_all_compilations"),
271-
272270
},
273271
"dependency_analysis": {
274272
"suggest_missing_dependencies": _load_export(

Core/engines_loader/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def environment(self, gui, file: str) -> Optional[dict[str, str]]:
7575
"""
7676
return None
7777

78-
def should_compile_file(self, gui, file: str, selected_files: list[str], python_files: list[str]) -> bool:
78+
def should_compile_file(
79+
self, gui, file: str, selected_files: list[str], python_files: list[str]
80+
) -> bool:
7981
"""
8082
Determine if a file should be included in the compilation queue.
8183
Called by the compiler to filter files based on engine-specific criteria.

Core/engines_loader/registry.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@
4444

4545
def normalize_language_code(code: Optional[str]) -> str:
4646
"""Normalize language code with fallback chain.
47-
47+
4848
Returns normalized code or 'en' as ultimate fallback.
4949
"""
5050
if not code:
5151
return "en"
52-
52+
5353
try:
5454
raw = str(code)
5555
low = raw.lower().replace("_", "-")
5656
mapped = _LANG_ALIASES.get(low, raw)
57-
57+
5858
# Candidate order: mapped -> base (before '-') -> exact lower -> exact raw -> 'en'
5959
candidates = []
6060
if mapped not in candidates:
6161
candidates.append(mapped)
62-
62+
6363
base = None
6464
try:
6565
if "-" in mapped:
@@ -68,7 +68,7 @@ def normalize_language_code(code: Optional[str]) -> str:
6868
base = mapped.split("_", 1)[0]
6969
except Exception:
7070
base = None
71-
71+
7272
if base and base not in candidates:
7373
candidates.append(base)
7474
if low not in candidates:
@@ -77,34 +77,34 @@ def normalize_language_code(code: Optional[str]) -> str:
7777
candidates.append(raw)
7878
if "en" not in candidates:
7979
candidates.append("en")
80-
80+
8181
return candidates[0] if candidates else "en"
8282
except Exception:
8383
return "en"
8484

8585

8686
def resolve_language_code(gui, tr: Optional[dict]) -> str:
8787
"""Resolve language code from translations metadata or GUI preferences.
88-
88+
8989
Returns normalized language code.
9090
"""
9191
code = None
92-
92+
9393
try:
9494
if isinstance(tr, dict):
9595
meta = tr.get("_meta", {})
9696
code = meta.get("code") if isinstance(meta, dict) else None
9797
except Exception:
9898
code = None
99-
99+
100100
if not code:
101101
try:
102102
pref = getattr(gui, "language_pref", getattr(gui, "language", "System"))
103103
if isinstance(pref, str) and pref != "System":
104104
code = pref
105105
except Exception:
106106
pass
107-
107+
108108
return normalize_language_code(code)
109109

110110

Core/i18n.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
# Built-in fallback for English if language files are missing
2525
FALLBACK_EN: dict[str, Any] = {
26+
"name": "English",
27+
"code": "en",
2628
"_meta": {"code": "en", "name": "English"},
27-
# Sidebar & main buttons
2829
"select_folder": "📁 Workspace",
2930
"select_files": "📋 Files",
3031
"build_all": "🚀 Build",
@@ -33,44 +34,40 @@
3334
"cancel_all": "⛔ Cancel",
3435
"suggest_deps": "🔎 Analyze dependencies",
3536
"help": "❓ Help",
37+
"help_title": "Help",
38+
"help_text": "<b>PyCompiler ARK++ — Quick Help</b><br><ul><li>1) Select the Workspace and add your .py files.</li><li>2) Configure pre‑compile plugins via <b>API Loader</b> (BCASL).</li><li>3) Configure options in the <b>PyInstaller</b>, <b>Nuitka</b> or <b>CX_Freeze</b> tab.</li><li>4) Click <b>Build</b> and follow the logs.</li></ul><b>Notes</b><br><ul><li>When a build starts, all action controls are disabled (including API Loader) until it finishes or is canceled.</li><li>Pre‑compilation (BCASL) completes before compilation.</li><li>A <i>venv</i> can be created automatically; requirements.txt is installed if present; tools are installed into the venv as needed.</li><li>API‑initiated workspace changes are auto‑applied; running builds are canceled before switching.</li></ul><b>License</b>: Apache-2.0 — <a href='https://www.apache.org/licenses/LICENSE-2.0'>apache.org/licenses/LICENSE-2.0</a><br><b>Author</b>: Ague Samuel Amen<br>© 2026 Ague Samuel Amen",
3639
"show_stats": "📊 Statistics",
3740
"select_lang": "Choose language",
38-
"select_theme": "Choose theme",
39-
"choose_theme_button": "Choose theme",
40-
"choose_theme_system_button": "Choose theme (System)",
41-
# Workspace
4241
"venv_button": "Choose venv folder manually",
4342
"label_workspace_section": "1. Select workspace folder",
4443
"venv_label": "venv selected: None",
4544
"label_folder": "No folder selected",
46-
# Files
4745
"label_files_section": "2. Files to build",
4846
"btn_remove_file": "🗑️ Remove selected file",
49-
# Logs
5047
"label_logs_section": "Build logs",
51-
# PyInstaller tab
52-
"tab_pyinstaller": "PyInstaller",
53-
"opt_onefile": "Onefile",
54-
"opt_windowed": "Windowed",
55-
"opt_noconfirm": "Noconfirm",
56-
"opt_clean": "Clean",
57-
"opt_noupx": "No UPX",
58-
"opt_main_only": "Build only main.py or app.py",
59-
"btn_select_icon": "🎨 Choose icon (.ico)",
60-
"opt_debug": "Debug mode (--debug)",
61-
"opt_auto_install": "Auto-install missing modules",
62-
"opt_silent_errors": "Do not show error box (silent mode)",
63-
# Nuitka tab
64-
"tab_nuitka": "Nuitka",
65-
"nuitka_onefile": "Onefile (--onefile)",
66-
"nuitka_standalone": "Standalone (--standalone)",
67-
"nuitka_disable_console": "Disable Windows console (--windows-disable-console)",
68-
"nuitka_show_progress": "Show progress (--show-progress)",
69-
# "nuitka_plugins": removed (auto-managed)
70-
"nuitka_output_dir": "Output folder (--output-dir)",
71-
"btn_nuitka_icon": "🎨 Choose Nuitka icon (.ico)",
48+
"choose_language_title": "Choose language",
49+
"choose_language_label": "Language:",
50+
"choose_language_system": "System",
51+
"choose_language_system_button": "Choose language (System)",
52+
"choose_language_button": "Choose language",
53+
"select_theme": "Choose theme",
54+
"choose_theme_button": "Choose theme",
55+
"choose_theme_system_button": "Choose theme (System)",
56+
"tt_select_folder": "Select the workspace directory containing your Python files.",
57+
"tt_select_files": "Add Python files manually to the build list.",
58+
"tt_build_all": "Start building all selected files.",
59+
"tt_export_config": "Export the current configuration to a JSON file.",
60+
"tt_import_config": "Import a configuration from a JSON file.",
61+
"tt_cancel_all": "Cancel all ongoing builds.",
62+
"tt_remove_file": "Remove the selected file(s) from the list.",
63+
"tt_help": "Open help and information about the software.",
64+
"tt_bc_loader": "Configure API (BCASL) plugins to run before compilation.",
65+
"tt_venv_button": "Manually select a venv directory to use for compilation.",
66+
"tt_suggest_deps": "Analyze the project for missing Python dependencies.",
67+
"tt_show_stats": "Show build statistics (time, number of files, memory).",
7268
}
7369

70+
7471
# Cache global pour les traductions chargées (évite les rechargements)
7572
_TRANSLATION_CACHE: dict[str, dict[str, Any]] = {}
7673
_LANGUAGES_CACHE: list[dict[str, str]] | None = None

ENGINES/cx_freeze/__init__.py

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
from engine_sdk import engine_register
3232

3333

34-
3534
@engine_register
3635
class 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

Comments
 (0)