diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 5801e1497a..2790820a5a 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -26,7 +26,9 @@ _PACKAGE_MAPPING = {"pytorch": "pytorch_lightning", "app": "lightning_app"} def _load_py_module(name: str, location: str) -> ModuleType: spec = spec_from_file_location(name, location) + assert spec, f"Failed to load module {name} from {location}" py = module_from_spec(spec) + assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}" spec.loader.exec_module(py) return py diff --git a/pyproject.toml b/pyproject.toml index dc9db77d6d..51781d4953 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,6 +95,5 @@ module = [ "pytorch_lightning.utilities.data", "pytorch_lightning.utilities.distributed", "pytorch_lightning.utilities.meta", - "pytorch_lightning.__setup__", ] ignore_errors = "True" diff --git a/setup.py b/setup.py index 0ff57c3f85..a542b3c1e0 100755 --- a/setup.py +++ b/setup.py @@ -74,7 +74,9 @@ with open(__file__, "w") as fp: def _load_py_module(name: str, location: str) -> ModuleType: spec = spec_from_file_location(name, location) + assert spec, f"Failed to load module {name} from {location}" py = module_from_spec(spec) + assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}" spec.loader.exec_module(py) return py diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index f549419bf7..93679c2b88 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -15,7 +15,9 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0))) def _load_py_module(name: str, location: str) -> ModuleType: spec = spec_from_file_location(name, location) + assert spec, f"Failed to load module {name} from {location}" py = module_from_spec(spec) + assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}" spec.loader.exec_module(py) return py diff --git a/src/lightning_app/__setup__.py b/src/lightning_app/__setup__.py index e989a17b50..2a738f20c6 100644 --- a/src/lightning_app/__setup__.py +++ b/src/lightning_app/__setup__.py @@ -14,7 +14,9 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0))) def _load_py_module(name: str, location: str) -> ModuleType: spec = spec_from_file_location(name, location) + assert spec, f"Failed to load module {name} from {location}" py = module_from_spec(spec) + assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}" spec.loader.exec_module(py) return py diff --git a/src/pytorch_lightning/__setup__.py b/src/pytorch_lightning/__setup__.py index 4b28df6829..8fd93c77ee 100644 --- a/src/pytorch_lightning/__setup__.py +++ b/src/pytorch_lightning/__setup__.py @@ -15,7 +15,9 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0))) def _load_py_module(name: str, location: str) -> ModuleType: spec = spec_from_file_location(name, location) + assert spec, f"Failed to load module {name} from {location}" py = module_from_spec(spec) + assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}" spec.loader.exec_module(py) return py