@@ -59,20 +59,36 @@ class MesonpyFinder(importlib.abc.MetaPathFinder):
5959
6060 def __init__ (
6161 self ,
62+ project_name : str ,
63+ hook_name : str ,
6264 project_path : str ,
6365 build_path : str ,
6466 import_paths : List [str ],
6567 top_level_modules : List [str ],
6668 rebuild_commands : List [List [str ]],
6769 verbose : bool = False ,
6870 ) -> None :
71+ self ._project_name = project_name
72+ self ._hook_name = hook_name
6973 self ._project_path = project_path
7074 self ._build_path = build_path
7175 self ._import_paths = import_paths
7276 self ._top_level_modules = top_level_modules
7377 self ._rebuild_commands = rebuild_commands
7478 self ._verbose = verbose
7579
80+ for path in (self ._project_path , self ._build_path ):
81+ if not os .path .isdir (path ):
82+ raise ImportError (
83+ f'{ path } is not a directory, but it is required to rebuild '
84+ f'"{ self ._project_name } ", which is installed in editable '
85+ 'mode. Please reinstall the project to get it back to '
86+ 'working condition. If there are any issues uninstalling '
87+ 'this installation, you can manually remove '
88+ f'{ self ._hook_name } and { os .path .basename (__file__ )} , '
89+ f'located in { os .path .dirname (__file__ )} .'
90+ )
91+
7692 def __repr__ (self ) -> str :
7793 return f'{ self .__class__ .__name__ } ({ self ._project_path } )'
7894
@@ -128,6 +144,8 @@ def find_spec(
128144 @classmethod
129145 def install (
130146 cls ,
147+ project_name : str ,
148+ hook_name : str ,
131149 project_path : str ,
132150 build_path : str ,
133151 import_paths : List [str ],
@@ -140,7 +158,16 @@ def install(
140158 if os .environ .get ('MESONPY_EDITABLE_VERBOSE' , '' ):
141159 verbose = True
142160 # install our finder
143- finder = cls (project_path , build_path , import_paths , top_level_modules , rebuild_commands , verbose )
161+ finder = cls (
162+ project_name ,
163+ hook_name ,
164+ project_path ,
165+ build_path ,
166+ import_paths ,
167+ top_level_modules ,
168+ rebuild_commands ,
169+ verbose ,
170+ )
144171 if finder not in sys .meta_path :
145172 # prepend our finder to sys.meta_path, so that it is queried before
146173 # the normal finders, and can trigger a project rebuild
0 commit comments