Skip to content

Commit

Permalink
Exclude builtin test.support modules from being loaded with Operation…
Browse files Browse the repository at this point in the history
… Modules (#2299)
  • Loading branch information
samtygier-stfc authored Aug 1, 2024
2 parents ae9b136 + cda45da commit 4370485
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mantidimaging/core/operations/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def _find_operation_modules() -> list[BaseFilterClass]:
continue

if getattr(sys, 'frozen', False):
# Need to prevent importing standard library test modules found by pkgutil
if "test.support" in module_name:
continue
# If we're running a PyInstaller executable then we need to use a full module path
module_name = f'mantidimaging.core.operations.{module_name}'

Expand Down
5 changes: 4 additions & 1 deletion packaging/PackageWithPyInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def add_hidden_imports(run_options):
path_to_operations = Path(__file__).parent.parent.joinpath('mantidimaging/core/operations')
# COMPAT python 3.10 won't accept a Path: github.com/python/cpython/issues/88227
for _, ops_module, _ in pkgutil.walk_packages([str(path_to_operations)]):
imports.append(f'mantidimaging.core.operations.{ops_module}')
# stop non-existent Hidden Imports
# https://github.com/mantidproject/mantidimaging/issues/2298
if "test.support" not in ops_module:
imports.append(f'mantidimaging.core.operations.{ops_module}')

run_options.extend([f'--hidden-import={name}' for name in imports])

Expand Down

0 comments on commit 4370485

Please sign in to comment.