Skip to content

Commit 75fb0a1

Browse files
committed
Corrige le mode headless et nettoie la documentation
1 parent 12a8299 commit 75fb0a1

12 files changed

Lines changed: 369 additions & 127 deletions

EngineLoader/__init__.py

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,58 @@
2121

2222
from . import registry as registry # re-export registry module
2323
from .base import CompilerEngine # re-export base type
24-
from .registry import unload_all # re-export unload_all function
25-
from .registry import get_engine # re-export get_engine function
26-
from .registry import available_engines # re-export available_engines function
27-
from .registry import create # re-export create function
24+
from .registry import unload_all as _registry_unload_all
25+
from .registry import get_engine as _registry_get_engine
26+
from .registry import available_engines as _registry_available_engines
27+
from .registry import create as _registry_create
2828

2929
__version__ = "1.0.0"
3030

31+
_DISCOVERY_DONE = False
3132

32-
# Perform discovery at import-time so engines are ready for UI/compile usage (packages under ENGINES/ only)
33-
try:
34-
if str(os.environ.get("ARK_ENGINES_AUTO_DISCOVER", "1")).lower() not in (
35-
"0",
36-
"false",
37-
"no",
38-
):
39-
_auto_discover()
40-
except Exception:
41-
pass
33+
34+
def _ensure_discovered() -> None:
35+
"""Load project engines on first real registry access.
36+
37+
Keeping discovery lazy avoids importing every engine package during harmless
38+
module imports such as CLI headless bootstrap or SDK helper loading.
39+
"""
40+
global _DISCOVERY_DONE
41+
if _DISCOVERY_DONE:
42+
return
43+
try:
44+
if str(os.environ.get("ARK_ENGINES_AUTO_DISCOVER", "1")).lower() not in (
45+
"0",
46+
"false",
47+
"no",
48+
):
49+
_auto_discover()
50+
except Exception:
51+
pass
52+
finally:
53+
_DISCOVERY_DONE = True
54+
55+
56+
def get_engine(eid: str):
57+
_ensure_discovered()
58+
return _registry_get_engine(eid)
59+
60+
61+
def available_engines() -> list[str]:
62+
_ensure_discovered()
63+
return _registry_available_engines()
64+
65+
66+
def create(eid: str):
67+
_ensure_discovered()
68+
return _registry_create(eid)
69+
70+
71+
def unload_all():
72+
global _DISCOVERY_DONE
73+
result = _registry_unload_all()
74+
_DISCOVERY_DONE = False
75+
return result
4276

4377
__all__ = [
4478
"CompilerEngine",

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Python project build workshop with a Qt GUI, a headless-friendly CLI, a BCASL
88

99
---
1010

11-
## Why this app ?
11+
## Why this app?
1212

1313
Build Python apps with a predictable workflow, a configurable pre-compile pipeline, and the freedom to choose your build engine.
1414

@@ -90,7 +90,7 @@ python pycompiler_ark.py engine list --json
9090
python pycompiler_ark.py engine doctor nuitka src/main.py --json
9191
python pycompiler_ark.py workspace inspect . --json
9292
python pycompiler_ark.py doctor --json
93-
python pycompiler_ark.py ci smoke . --json --strict --require-entrypoint
93+
python pycompiler_ark.py ci smoke /path/to/workspace --json --strict --require-entrypoint
9494
python pycompiler_ark.py scaffold engine demo_engine --json
9595
python pycompiler_ark.py unload --json
9696
```
@@ -107,19 +107,20 @@ python pycompiler_ark.py unload --json
107107

108108
### Headless note
109109

110-
The CLI bootstrap no longer forces Qt for purely headless commands such as:
110+
The CLI router no longer bootstraps the main Qt application for headless paths such as:
111111

112112
- `--help`
113113
- `--version`
114114
- `--info`
115115
- `--cli`
116116
- `unload`
117-
- `engine ...`
118117
- `workspace ...`
119-
- `doctor`
120-
- `scaffold ...`
121118

122-
This makes scripting and CI friendlier on machines where the GUI stack is unavailable or intentionally not used.
119+
Structured command groups such as `engine`, `bcasl`, `doctor`, `ci`, and `scaffold`
120+
also avoid launching the main GUI entrypoint.
121+
122+
This keeps scripting and CI workflows friendly on machines where no GUI window
123+
should be opened.
123124

124125
### CI-friendly exit codes
125126

@@ -180,7 +181,7 @@ python -m OnlyMod.EngineOnlyMod --engine nuitka -f script.py --dry-run
180181

181182
## Configuration
182183

183-
- **`ARK_Main_Config.yml`**: inclusion and exclusion patterns, BCASL options.
184+
- **`ARK_Main_Config.yml`**: inclusion/exclusion patterns, build entrypoint, and a few workspace-level defaults consumed by BCASL bootstrap.
184185
- **`bcasl.yml`**: plugin enable/disable, order, and timeouts.
185186

186187
---
@@ -214,7 +215,7 @@ python -m py_compile pycompiler_ark.py
214215
python -m pycompiler_ark --help
215216
python -m pycompiler_ark workspace inspect . --json
216217
python -m pycompiler_ark engine list --json
217-
python -m pycompiler_ark ci smoke . --json --strict --require-entrypoint
218+
python -m pycompiler_ark ci smoke /path/to/workspace --json --strict --require-entrypoint
218219
```
219220

220221
Quality status:

cli/entrypoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def main(argv: list[str] | None = None) -> int:
3737
if has_click():
3838
try:
3939
cli = build_cli(app_version)
40-
cli.main(args=args, prog_name="pycompiler_ark", standalone_mode=False)
41-
return 0
40+
result = cli.main(args=args, prog_name="pycompiler_ark", standalone_mode=False)
41+
return int(result) if isinstance(result, int) else 0
4242
except SystemExit as exc:
4343
return int(exc.code) if isinstance(exc.code, int) else 0
4444
except Exception:

0 commit comments

Comments
 (0)