Skip to content

Commit 3a7772b

Browse files
committed
feat: ajout de build.include pour forcer l'inclusion de packages Python (UI, Core et Moteurs)
1 parent 7d4fa63 commit 3a7772b

9 files changed

Lines changed: 52 additions & 2 deletions

File tree

Core/AdvancedConfigEditor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ def validate_ark_payload(data: Any) -> tuple[list[str], list[str]]:
104104
):
105105
errs.append("build.exclude must be a list of strings.")
106106

107+
include = build.get("include")
108+
if include is not None and (
109+
not isinstance(include, list)
110+
or not all(isinstance(item, str) for item in include)
111+
):
112+
errs.append("build.include must be a list of strings.")
113+
107114
data_map = build.get("data")
108115
if data_map is not None:
109116
if not isinstance(data_map, list):

Core/Locking/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def build_context_from_ark_config(config: dict[str, Any]) -> BuildContext:
347347
entry_point=str(project.get("entry") or ""),
348348
output_dir=str(build.get("output") or ""),
349349
exclude_patterns=list(build.get("exclude") or []),
350+
include_packages=list(build.get("include") or []),
350351
data_mappings=list(build.get("data") or []),
351352
icon=str(build.get("icon")) if build.get("icon") else None,
352353
)
@@ -367,6 +368,7 @@ def build_context_from_lock(lock_payload: dict[str, Any]) -> BuildContext:
367368
entry_point=str(project.get("entry") or ""),
368369
output_dir=str(build.get("output") or ""),
369370
exclude_patterns=exclude_patterns,
371+
include_packages=list(build.get("include") or []),
370372
data_mappings=list(build.get("data") or []),
371373
icon=str(build.get("icon")) if build.get("icon") else None,
372374
)

Core/engine/build_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class BuildContext:
2727
entry_point: str
2828
output_dir: str
2929
exclude_patterns: list[str]
30+
include_packages: list[str]
3031
data_mappings: list[
3132
dict[str, Any]
3233
] # Each dict: {"source": str, "destination": str, "type": "file" | "dir"}

Ui/Gui/Compilation/compiler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ def compile(
218218
return False
219219

220220
ctx = BuildContext(
221+
project_name=os.path.basename(file_path),
221222
entry_point=os.path.basename(file_path),
222223
output_dir="dist/",
224+
exclude_patterns=[],
225+
include_packages=[],
226+
data_mappings=[],
223227
)
224228
return self.compile_from_context(
225229
workspace=Path(workspace_dir or os.getcwd()),

Ui/Gui/Dialogs/AdvancedConfigEditor.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,20 @@ def __init__(self, gui):
215215
lay_exclude.addWidget(
216216
QLabel(
217217
self.gui.tr(
218-
"Exclusions Workspace (filtre GUI):",
218+
"Inclusions Build (Packages Python à forcer dans le bundle) :",
219+
"Build Inclusions (Python packages to force into the bundle):",
220+
)
221+
)
222+
)
223+
self.edit_build_include = QPlainTextEdit()
224+
self.edit_build_include.setPlaceholderText("my_custom_lib\nrare_package")
225+
self.edit_build_include.setMaximumHeight(80)
226+
lay_exclude.addWidget(self.edit_build_include)
227+
228+
lay_exclude.addWidget(
229+
QLabel(
230+
self.gui.tr(
231+
"Exclusions Workspace (filtre GUI) :",
219232
"Workspace Exclusions (GUI filter):",
220233
)
221234
)
@@ -284,6 +297,10 @@ def _load_config(self) -> None:
284297
if isinstance(build_exclude, list):
285298
self.edit_build_exclude.setPlainText("\n".join(build_exclude))
286299

300+
build_include = build.get("include", [])
301+
if isinstance(build_include, list):
302+
self.edit_build_include.setPlainText("\n".join(build_include))
303+
287304
workspace = config.get("workspace", {})
288305
ws_exclude = workspace.get("exclude", [])
289306
if isinstance(ws_exclude, list):
@@ -357,6 +374,11 @@ def _on_save(self) -> None:
357374
for line in self.edit_build_exclude.toPlainText().splitlines()
358375
if line.strip()
359376
],
377+
"include": [
378+
line.strip()
379+
for line in self.edit_build_include.toPlainText().splitlines()
380+
if line.strip()
381+
],
360382
"data": data_map,
361383
},
362384
"plugins": {

engines/cx_freeze/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def build_command(self, context: BuildContext) -> list[str]:
111111
if verbose_enabled:
112112
cmd.append("--verbose")
113113

114+
for module in context.include_packages:
115+
if module.strip():
116+
cmd.extend(["--includes", module.strip()])
117+
114118
for mapping in context.data_mappings:
115119
source = str((mapping or {}).get("source") or "").strip()
116120
destination = str((mapping or {}).get("destination") or "").strip()

engines/nuitka/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def build_command(self, context: BuildContext) -> list[str]:
130130
if module and "*" not in module:
131131
cmd.append(f"--nofollow-import-to={module.replace('/', '.')}")
132132

133+
for module in context.include_packages:
134+
if module.strip():
135+
cmd.append(f"--include-package={module.strip()}")
136+
133137
for mapping in context.data_mappings:
134138
source = str((mapping or {}).get("source") or "").strip()
135139
destination = str((mapping or {}).get("destination") or "").strip()

engines/pyinstaller/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ def build_command(self, context: BuildContext) -> list[str]:
115115
if module and "*" not in module:
116116
cmd.extend(["--exclude-module", module.replace("/", ".")])
117117

118+
for module in context.include_packages:
119+
if module.strip():
120+
cmd.extend(["--collect-all", module.strip()])
121+
118122
separator = ";" if platform.system() == "Windows" else ":"
119123
for mapping in context.data_mappings:
120124
source = str((mapping or {}).get("source") or "").strip()

todo.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,6 @@ Plugins: 2/2 ok, temps total 2009.0 ms
140140

141141
- [x] en fonction des derniere modification des docs sur lutlisation de `build.exclude` dans la cfg managed par le logiciel , ... modification de advancededitor car au message de fond de la section dediée a `build.exclude` il ya des exlusiond de dossier et Pycache comme exemple ... modifer vers des un message de fond parlt de exclusion de package python.
142142

143-
- [x] lors de la creation de .ark/ dans un dworkspace un gitingore doit etre ajouter permetant dexclure le ficheor pref.json le dossier cache le dossier logs et build uniquement.
143+
- [x] lors de la creation de .ark/ dans un dworkspace un gitingore doit etre ajouter permetant dexclure le ficheor pref.json le dossier cache le dossier logs et build uniquement.
144+
145+
- [x] Implémentation de `build.include` dans ark.yml et l'UI pour permettre de forcer l'inclusion de packages Python (traduction automatique pour Nuitka, PyInstaller et cx_Freeze).

0 commit comments

Comments
 (0)