Fall through to default behavior when pyinstall toc is not found (#3256)

Close #3255
This commit is contained in:
Joe Jensen
2025-01-31 10:14:27 +01:00
committed by GitHub
parent 2bc25a32e4
commit b4eab48971
+3
View File
@@ -38,6 +38,9 @@ def iter_modules(package: str) -> List[str]:
for importer in pkgutil.iter_importers(): for importer in pkgutil.iter_importers():
if hasattr(importer, 'toc'): if hasattr(importer, 'toc'):
toc |= getattr(importer, 'toc') toc |= getattr(importer, 'toc')
# If it found the pyinstaller toc then use it, otherwise fall through to default
# behavior which works in pyinstaller >= 4.4
if len(toc) > 0:
dots = module_prefix.count('.') # search for modules only on the same level dots = module_prefix.count('.') # search for modules only on the same level
return [module for module in toc if module.startswith(module_prefix) and module.count('.') == dots] return [module for module in toc if module.startswith(module_prefix) and module.count('.') == dots]