@@ -359,23 +359,41 @@ def install_pyaedt():
359359 command .append ("pyaedt[all]" )
360360 subprocess .run (command , check = True , env = env ) # nosec
361361 else :
362- # Install uv in the virtual environment
363- print ("Installing uv in the virtual environment..." )
364- subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "uv" ], check = True , env = env ) # nosec
365-
366- print ("Installing PyAEDT using online sources with uv..." )
367- subprocess .run ([str (uv_exe ), "pip" , "install" , "--upgrade" , "pip" ], check = True , env = env ) # nosec
368- subprocess .run ([str (uv_exe ), "pip" , "install" , "wheel" ], check = True , env = env ) # nosec
369- if args .version <= "231" :
370- subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]=='0.9.0'" ] , check = True , env = env ) # nosec
371- subprocess .run ([str (uv_exe ), "pip" , "install" , "jupyterlab" ], check = True , env = env ) # nosec
372- subprocess .run ([str (uv_exe ), "pip" , "install" , "ipython" , "-U" ], check = True , env = env ) # nosec
373- subprocess .run ([str (uv_exe ), "pip" , "install" , "ipyvtklink" ], check = True , env = env ) # nosec
374- else :
375- subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]" ], check = True , env = env ) # nosec
362+ # Try to install uv and use it, fallback to pip if it fails
363+ uv_available = True
364+ try :
365+ print ("Installing uv in the virtual environment..." )
366+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "uv" ], check = True , env = env ) # nosec
367+ print ("Installing PyAEDT using online sources with uv..." )
368+ subprocess .run ([str (uv_exe ), "pip" , "install" , "--upgrade" , "pip" ], check = True , env = env ) # nosec
369+ subprocess .run ([str (uv_exe ), "pip" , "install" , "wheel" ], check = True , env = env ) # nosec
370+ if args .version <= "231" :
371+ subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]=='0.9.0'" ] , check = True , env = env ) # nosec
372+ subprocess .run ([str (uv_exe ), "pip" , "install" , "jupyterlab" ], check = True , env = env ) # nosec
373+ subprocess .run ([str (uv_exe ), "pip" , "install" , "ipython" , "-U" ], check = True , env = env ) # nosec
374+ subprocess .run ([str (uv_exe ), "pip" , "install" , "ipyvtklink" ], check = True , env = env ) # nosec
375+ else :
376+ subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]" ], check = True , env = env ) # nosec
377+ except subprocess .CalledProcessError as e :
378+ print (f"uv installation failed with error: { e } " )
379+ print ("Falling back to pip for package installation..." )
380+ uv_available = False
381+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "--upgrade" , "pip" ], check = True , env = env ) # nosec
382+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "wheel" ], check = True , env = env ) # nosec
383+ if args .version <= "231" :
384+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "pyaedt[all,dotnet]=='0.9.0'" ], check = True , env = env ) # nosec
385+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "jupyterlab" ], check = True , env = env ) # nosec
386+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "ipython" , "-U" ], check = True , env = env ) # nosec
387+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "ipyvtklink" ], check = True , env = env ) # nosec
388+ else :
389+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "pyaedt[all]" ], check = True , env = env ) # nosec
376390
377391 if args .version <= "231" :
378- subprocess .run ([str (uv_exe ), "pip" , "uninstall" , "pywin32" ], check = True , env = env ) # nosec
392+ try :
393+ subprocess .run ([str (uv_exe ), "pip" , "uninstall" , "pywin32" ], check = True , env = env ) # nosec
394+ except subprocess .CalledProcessError :
395+ # If uv fails, use pip instead
396+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "uninstall" , "pywin32" , "-y" ], check = True , env = env ) # nosec
379397
380398 else :
381399 print ("Using existing virtual environment in {}" .format (venv_dir ))
@@ -409,18 +427,31 @@ def install_pyaedt():
409427 command .append ("pyaedt[all]" )
410428 subprocess .run (command , check = True , env = env ) # nosec
411429 else :
412- # Ensure uv is installed in the venv
413- subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "uv" ], check = True , env = env ) # nosec
414- subprocess .run ([str (uv_exe ), "pip" , "uninstall" , "pyaedt" ], check = True , env = env ) # nosec
415-
416- print ("Installing PyAEDT using online sources with uv..." )
417- if args .version <= "231" :
418- subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]=='0.9.0'" ] , check = True , env = env ) # nosec
419- subprocess .run ([str (uv_exe ), "pip" , "install" , "jupyterlab" ], check = True , env = env ) # nosec
420- subprocess .run ([str (uv_exe ), "pip" , "install" , "ipython" , "-U" ], check = True , env = env ) # nosec
421- subprocess .run ([str (uv_exe ), "pip" , "install" , "ipyvtklink" ], check = True , env = env ) # nosec
422- else :
423- subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]" ], check = True , env = env ) # nosec
430+ # Try to use uv for package installation, fallback to pip if it fails
431+ try :
432+ # Ensure uv is installed in the venv
433+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "uv" ], check = True , env = env ) # nosec
434+ subprocess .run ([str (uv_exe ), "pip" , "uninstall" , "pyaedt" ], check = True , env = env ) # nosec
435+
436+ print ("Installing PyAEDT using online sources with uv..." )
437+ if args .version <= "231" :
438+ subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]=='0.9.0'" ] , check = True , env = env ) # nosec
439+ subprocess .run ([str (uv_exe ), "pip" , "install" , "jupyterlab" ], check = True , env = env ) # nosec
440+ subprocess .run ([str (uv_exe ), "pip" , "install" , "ipython" , "-U" ], check = True , env = env ) # nosec
441+ subprocess .run ([str (uv_exe ), "pip" , "install" , "ipyvtklink" ], check = True , env = env ) # nosec
442+ else :
443+ subprocess .run ([str (uv_exe ), "pip" , "install" , "pyaedt[all]" ], check = True , env = env ) # nosec
444+ except subprocess .CalledProcessError as e :
445+ print (f"uv installation failed with error: { e } " )
446+ print ("Falling back to pip for package installation..." )
447+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "uninstall" , "pyaedt" , "-y" ], check = True , env = env ) # nosec
448+ if args .version <= "231" :
449+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "pyaedt[all,dotnet]=='0.9.0'" ], check = True , env = env ) # nosec
450+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "jupyterlab" ], check = True , env = env ) # nosec
451+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "ipython" , "-U" ], check = True , env = env ) # nosec
452+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "ipyvtklink" ], check = True , env = env ) # nosec
453+ else :
454+ subprocess .run ([str (pip_exe ), "--default-timeout=1000" , "install" , "pyaedt[all]" ], check = True , env = env ) # nosec
424455 sys .exit (0 )
425456
426457
0 commit comments