Skip to content

Commit 003250e

Browse files
author
FlowCyt Dev
committed
fix(spec): collect ALL backend.app modules, not just endpoints
Root cause of exe startup crash (from launcher.log): ModuleNotFoundError: No module named 'backend.app.schemas.recommendations' backend/app/api/v1/router.py loads endpoints via importlib.import_module(), and several endpoints in turn import_module() their schemas (e.g. recommendations.py -> backend.app.schemas.recommendations). PyInstaller's static analysis can't follow these string-based imports, so the previous spec only collected endpoints/ and admin/endpoints/ — missing schemas/, services/, core/. Switch to rglob('*.py') under backend/app/ to collect every module in the package, eliminating the per-directory enumeration that kept missing dynamically-imported subpackages.
1 parent e297170 commit 003250e

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

‎panelagent.spec‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@ if out_dir.is_dir():
3939
datas.append((str(out_dir), str(Path("frontend") / "out")))
4040

4141
# --- Hidden imports (modules imported dynamically via importlib) ----------
42-
# Backend endpoints are loaded via importlib in router.py, so PyInstaller's
43-
# static analysis misses them — list them explicitly.
44-
_backend_endpoint_modules = []
45-
_endpoints_root = PROJECT_ROOT / "backend" / "app" / "api" / "v1" / "endpoints"
46-
if _endpoints_root.is_dir():
47-
for f in _endpoints_root.glob("*.py"):
48-
if f.stem != "__init__":
49-
_backend_endpoint_modules.append(f"backend.app.api.v1.endpoints.{f.stem}")
50-
_admin_endpoints_root = PROJECT_ROOT / "backend" / "app" / "api" / "v1" / "admin" / "endpoints"
51-
if _admin_endpoints_root.is_dir():
52-
for f in _admin_endpoints_root.glob("*.py"):
53-
if f.stem != "__init__":
54-
_backend_endpoint_modules.append(f"backend.app.api.v1.admin.endpoints.{f.stem}")
42+
# The backend loads endpoints, schemas and services via import_module() with
43+
# string literals (see backend/app/api/v1/router.py and the endpoints). PyInstaller's
44+
# static analysis cannot follow these, so we collect EVERY .py module under
45+
# backend/app/ plus the root-level domain modules.
46+
_backend_modules = []
47+
_backend_root = PROJECT_ROOT / "backend" / "app"
48+
if _backend_root.is_dir():
49+
for f in _backend_root.rglob("*.py"):
50+
if f.name == "__init__.py":
51+
continue
52+
rel = f.relative_to(PROJECT_ROOT).with_suffix("")
53+
_backend_modules.append(".".join(rel.parts))
5554

5655
hiddenimports = [
5756
"data_preprocessing",
@@ -69,7 +68,7 @@ hiddenimports = [
6968
"backend.app.main",
7069
# Data file dependencies pulled in by pandas/openpyxl at runtime.
7170
"openpyxl",
72-
] + _backend_endpoint_modules
71+
] + _backend_modules
7372

7473
a = Analysis(
7574
["launcher.py"],

0 commit comments

Comments
 (0)