summaryrefslogtreecommitdiff
path: root/bin/spack_cmd.bat
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2021-07-07 08:32:47 -0400
committerPeter Scheibel <scheibel1@llnl.gov>2022-03-17 09:01:01 -0700
commite65d3d14b4a7a9a9667b006bea1f9f2eafc69472 (patch)
treef1a68cf906847887b44b9fe9afcf4cfc618d4a87 /bin/spack_cmd.bat
parent4a73bfc3b9c4507f270951757475e514cd666ead (diff)
downloadspack-e65d3d14b4a7a9a9667b006bea1f9f2eafc69472.tar.gz
spack-e65d3d14b4a7a9a9667b006bea1f9f2eafc69472.tar.bz2
spack-e65d3d14b4a7a9a9667b006bea1f9f2eafc69472.tar.xz
spack-e65d3d14b4a7a9a9667b006bea1f9f2eafc69472.zip
Relocate spack_cmd and scripts from installer to root bin (#24651)
Relocate spack_cmd and scripts from installer to root bin Refactor documentation, installer, and launcher to facilitate that change
Diffstat (limited to 'bin/spack_cmd.bat')
-rw-r--r--bin/spack_cmd.bat61
1 files changed, 61 insertions, 0 deletions
diff --git a/bin/spack_cmd.bat b/bin/spack_cmd.bat
new file mode 100644
index 0000000000..6d851d5311
--- /dev/null
+++ b/bin/spack_cmd.bat
@@ -0,0 +1,61 @@
+@ECHO OFF
+setlocal EnableDelayedExpansion
+:: (c) 2021 Lawrence Livermore National Laboratory
+:: 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%\..
+set spackinstdir=%CD%
+popd
+
+
+:: Check if Python is on the PATH
+(for /f "delims=" %%F in ('where python.exe') do (set python_pf_ver=%%F) ) 2> NUL
+
+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 (
+ set python_ver=%%g)) 2> NUL
+
+ if not defined python_ver (
+ echo Python was not found on your system.
+ echo Please install Python or add Python to your PATH.
+ ) else (
+ set py_path=!spackinstdir!\!python_ver!
+ set py_exe=!py_path!\python.exe
+ )
+ goto :exitpoint
+) else (
+ :: Python is already on the path
+ set py_exe=!python_pf_ver!
+ (for /F "tokens=* USEBACKQ" %%F in (
+ `!py_exe! --version`) do (set "output=%%F")) 2>NUL
+ if not "!output:Microsoft Store=!"=="!output!" goto :get_builtin
+ goto :exitpoint
+)
+:exitpoint
+
+set "PATH=%SPACK_ROOT%\bin\;%PATH%"
+if defined py_path (
+ set "PATH=%py_path%;%PATH%"
+)
+
+if defined py_exe (
+ "%py_exe%" "%SPACK_ROOT%\bin\haspywin.py"
+ "%py_exe%" "%SPACK_ROOT%\bin\spack" external find python >NUL
+)
+
+set "EDITOR=notepad"
+
+DOSKEY spacktivate=spack env activate $*
+
+@echo **********************************************************************
+@echo ** Spack Package Manager
+@echo **********************************************************************
+
+%comspec% /k