@@ -193,59 +193,20 @@ def ls_recipe():
193193 print (get_recipes ())
194194
195195
196- def uninstall_recipe (wf_name : str ,
196+ def uninstall_recipe (module_name : str ,
197197 savedir : pathlib .Path = this_dir .joinpath ("recipes" )):
198198 """
199199 Uninstalls a recipe installed in the system.
200200 """
201201
202- dst = pathlib . Path ( savedir , f" { savedir .stem } _recipes" , wf_name ). resolve ()
202+ dst = f"wfcommons.wfchef.recipe. { savedir .stem } "
203203 try :
204- # Removing package from setup.py
205- with this_dir .joinpath (dst .parent .parent .joinpath ("setup.py" )).open ("r" ) as fp :
206- setup_str = fp .read ()
207-
208- # Find and remove the specific line that added the package
209- for line in setup_str .split ("\n " ):
210- if wf_name in setup_str :
211- setup_str = setup_str .replace (line , "" )
212-
213- with this_dir .joinpath (dst .parent .parent .joinpath ("setup.py" )).open ("w" ) as fp :
214- fp .write (setup_str )
215-
216- # Removing the import line from __init__.py
217- init_file = dst .parent .joinpath ("__init__.py" )
218- if init_file .exists ():
219- with init_file .open ("r" ) as fp :
220- init_str = fp .read ()
221-
222- # Remove the line that imports the package
223-
224- for line in init_str .split ("\n " ):
225- if wf_name in line :
226- init_str = init_str .replace (line , "" )
227- break
228-
229- with init_file .open ("w" ) as fp :
230- fp .write (init_str )
231-
232- # Removing the recipe directory
233- if dst .exists ():
234- print (f"Removing { dst } " )
235- subprocess .Popen (["rm" , "-rf" , str (dst )]).wait ()
236-
237- # Find setup.py, clean it and reinstall it
238- path_to_setup = this_dir .parent .parent .resolve ()
239- # Check if the setup.py is in the same directory
240- if path_to_setup .joinpath ("setup.py" ).exists ():
241- subprocess .Popen (["python" , "setup.py" , "clean" , "-all" ]).wait ()
242- subprocess .Popen (["python" , "setup.py" , "sdist" , "bdist_wheel" ]).wait ()
243- subprocess .Popen (["pip" , "install" , "." ]).wait ()
244- subprocess .Popen (["pip" , "cache" , "purge" ]).wait ()
245-
204+ subprocess .run (["pip" , "uninstall" , "-y" , dst ])
205+ traceback .print_exc ()
206+
246207 except Exception as e :
247208 traceback .print_exc ()
248- # print(f"Could not find recipe with module name {module_name} installed ")
209+ print (f"Could not uninstall recipe for { module_name } " )
249210
250211
251212def create_recipe (path_to_instances : Union [str , pathlib .Path ],
0 commit comments