From 95e8f77bec41d5a06a08293188fc12a7c96b40a8 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Tue, 27 May 2025 14:54:19 -0700 Subject: [PATCH 1/2] do not prematurely import app module if providing app_module_import --- reflex/config.py | 4 ++-- reflex/utils/exec.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/reflex/config.py b/reflex/config.py index 6ce3b873bab..2fcadb15227 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -988,8 +988,8 @@ def module(self) -> str: Returns: The module name. """ - if self.app_module is not None: - return self.app_module.__name__ + if self.app_module_import is not None: + return self.app_module_import return ".".join([self.app_name, self.app_name]) def update_from_env(self) -> dict[str, Any]: diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index 5caa1ad81fa..5cc3c6bd604 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -301,8 +301,12 @@ def get_reload_paths() -> Sequence[Path]: """ config = get_config() reload_paths = [Path(config.app_name).parent] - if config.app_module is not None and config.app_module.__file__: - module_path = Path(config.app_module.__file__).resolve().parent + if ( + config.app_module_import is not None + and (spec := importlib.util.find_spec(config.app_module_import)) is not None + and spec.origin + ): + module_path = Path(spec.origin).resolve().parent while module_path.parent.name and any( sibling_file.name == "__init__.py" From fb88abd6a5c90077bcf97958eb7d02f883d56a07 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Tue, 27 May 2025 15:01:38 -0700 Subject: [PATCH 2/2] use .module --- reflex/utils/exec.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index 5cc3c6bd604..93aa232b4c2 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -300,12 +300,8 @@ def get_reload_paths() -> Sequence[Path]: The reload paths for the backend. """ config = get_config() - reload_paths = [Path(config.app_name).parent] - if ( - config.app_module_import is not None - and (spec := importlib.util.find_spec(config.app_module_import)) is not None - and spec.origin - ): + reload_paths = [Path.cwd()] + if (spec := importlib.util.find_spec(config.module)) is not None and spec.origin: module_path = Path(spec.origin).resolve().parent while module_path.parent.name and any(