4040from reflex .environment import environment
4141from reflex .utils import console , net , path_ops , processes , redir
4242from reflex .utils .exceptions import SystemPackageMissingError
43+ from reflex .utils .misc import get_module_path
4344from reflex .utils .registry import get_npm_registry
4445
4546if typing .TYPE_CHECKING :
@@ -348,14 +349,11 @@ def _check_app_name(config: Config):
348349 )
349350 raise RuntimeError (msg )
350351
351- from reflex .utils .misc import with_cwd_in_syspath
352+ from reflex .utils .misc import get_module_path , with_cwd_in_syspath
352353
353354 with with_cwd_in_syspath ():
354- try :
355- mod_spec = importlib .util .find_spec (config .module )
356- except ModuleNotFoundError :
357- mod_spec = None
358- if mod_spec is None :
355+ module_path = get_module_path (config .module )
356+ if module_path is None :
359357 msg = f"Module { config .module } not found. "
360358 if config .app_module_import is not None :
361359 msg += f"Ensure app_module_import='{ config .app_module_import } ' in rxconfig.py matches your folder structure."
@@ -740,14 +738,11 @@ def rename_app(new_app_name: str, loglevel: constants.LogLevel):
740738 sys .path .insert (0 , str (Path .cwd ()))
741739
742740 config = get_config ()
743- module_path = importlib . util . find_spec (config .module )
741+ module_path = get_module_path (config .module )
744742 if module_path is None :
745743 console .error (f"Could not find module { config .module } ." )
746744 raise click .exceptions .Exit (1 )
747745
748- if not module_path .origin :
749- console .error (f"Could not find origin for module { config .module } ." )
750- raise click .exceptions .Exit (1 )
751746 console .info (f"Renaming app directory to { new_app_name } ." )
752747 process_directory (
753748 Path .cwd (),
@@ -756,7 +751,7 @@ def rename_app(new_app_name: str, loglevel: constants.LogLevel):
756751 exclude_dirs = [constants .Dirs .WEB , constants .Dirs .APP_ASSETS ],
757752 )
758753
759- rename_path_up_tree (Path ( module_path . origin ) , config .app_name , new_app_name )
754+ rename_path_up_tree (module_path , config .app_name , new_app_name )
760755
761756 console .success (f"App directory renamed to [bold]{ new_app_name } [/bold]." )
762757
0 commit comments