| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | @ECHO OFF | 
					
						
							|  |  |  | setlocal EnableDelayedExpansion | 
					
						
							|  |  |  | :: (c) 2021 Lawrence Livermore National Laboratory | 
					
						
							| 
									
										
										
										
											2021-07-07 08:32:47 -04:00
										 |  |  | :: To use this file independently of Spack's installer, execute this script in its directory, or add the | 
					
						
							|  |  |  | :: associated bin directory to your PATH. Invoke to launch Spack Shell. | 
					
						
							|  |  |  | :: | 
					
						
							|  |  |  | :: source_dir/spack/bin/spack_cmd.bat | 
					
						
							|  |  |  | :: | 
					
						
							|  |  |  | pushd %~dp0.. | 
					
						
							|  |  |  | set SPACK_ROOT=%CD% | 
					
						
							|  |  |  | pushd %CD%\.. | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | set spackinstdir=%CD% | 
					
						
							|  |  |  | popd | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-07 08:32:47 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | :: Check if Python is on the PATH | 
					
						
							| 
									
										
										
										
											2022-01-25 17:29:17 -05:00
										 |  |  | if not defined python_pf_ver ( | 
					
						
							| 
									
										
										
										
											2021-10-22 14:00:02 -04:00
										 |  |  | (for /f "delims=" %%F in ('where python.exe') do ( | 
					
						
							| 
									
										
										
										
											2021-10-21 16:59:33 -04:00
										 |  |  |                                                     set "python_pf_ver=%%F" | 
					
						
							| 
									
										
										
										
											2021-10-22 14:00:02 -04:00
										 |  |  |                                                     goto :found_python | 
					
						
							|  |  |  |                                                   ) ) 2> NUL | 
					
						
							| 
									
										
										
										
											2022-01-25 17:29:17 -05:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2021-10-22 14:00:02 -04:00
										 |  |  | :found_python | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | if not defined python_pf_ver ( | 
					
						
							|  |  |  |     :: If not, look for Python from the Spack installer | 
					
						
							|  |  |  |     :get_builtin | 
					
						
							|  |  |  |     (for /f "tokens=*" %%g in ('dir /b /a:d "!spackinstdir!\Python*"') do ( | 
					
						
							| 
									
										
										
										
											2021-10-21 16:59:33 -04:00
										 |  |  |         set "python_ver=%%g")) 2> NUL | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if not defined python_ver ( | 
					
						
							|  |  |  |         echo Python was not found on your system. | 
					
						
							|  |  |  |         echo Please install Python or add Python to your PATH. | 
					
						
							|  |  |  |     ) else ( | 
					
						
							| 
									
										
										
										
											2021-10-21 16:59:33 -04:00
										 |  |  |         set "py_path=!spackinstdir!\!python_ver!" | 
					
						
							|  |  |  |         set "py_exe=!py_path!\python.exe" | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  |     ) | 
					
						
							|  |  |  |     goto :exitpoint | 
					
						
							|  |  |  | ) else ( | 
					
						
							|  |  |  |     :: Python is already on the path | 
					
						
							| 
									
										
										
										
											2021-10-21 16:59:33 -04:00
										 |  |  |     set "py_exe=!python_pf_ver!" | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  |     (for /F "tokens=* USEBACKQ" %%F in ( | 
					
						
							| 
									
										
										
										
											2021-10-22 14:00:02 -04:00
										 |  |  |         `"!py_exe!" --version`) do (set "output=%%F")) 2>NUL | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  |     if not "!output:Microsoft Store=!"=="!output!" goto :get_builtin | 
					
						
							|  |  |  |     goto :exitpoint | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | :exitpoint | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-07 08:32:47 -04:00
										 |  |  | set "PATH=%SPACK_ROOT%\bin\;%PATH%" | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | if defined py_path ( | 
					
						
							|  |  |  |     set "PATH=%py_path%;%PATH%" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if defined py_exe ( | 
					
						
							| 
									
										
										
										
											2021-07-07 08:32:47 -04:00
										 |  |  |     "%py_exe%" "%SPACK_ROOT%\bin\haspywin.py" | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  |     "%py_exe%" "%SPACK_ROOT%\bin\spack" external find python >NUL | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set "EDITOR=notepad" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DOSKEY spacktivate=spack env activate $* | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @echo ********************************************************************** | 
					
						
							|  |  |  | @echo ** Spack Package Manager | 
					
						
							|  |  |  | @echo ********************************************************************** | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-25 17:29:17 -05:00
										 |  |  | IF "%1"=="" GOTO CONTINUE | 
					
						
							|  |  |  | set | 
					
						
							|  |  |  | GOTO:EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | :continue | 
					
						
							| 
									
										
										
										
											2022-03-16 16:41:34 -04:00
										 |  |  | set PROMPT=[spack] %PROMPT% | 
					
						
							| 
									
										
										
										
											2021-01-08 15:48:07 -05:00
										 |  |  | %comspec% /k |