summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2024-10-25 15:23:29 -0400
committerGitHub <noreply@github.com>2024-10-25 15:23:29 -0400
commit7b27aed4c85b3cf492ec8686cbcd30f302ea0d52 (patch)
treec7076e018918670f6dd16d233ad5804f8be3c995 /share
parentad0b2564073ce91dfad2a49998c285525148a28a (diff)
downloadspack-7b27aed4c85b3cf492ec8686cbcd30f302ea0d52.tar.gz
spack-7b27aed4c85b3cf492ec8686cbcd30f302ea0d52.tar.bz2
spack-7b27aed4c85b3cf492ec8686cbcd30f302ea0d52.tar.xz
spack-7b27aed4c85b3cf492ec8686cbcd30f302ea0d52.zip
Normalize Spack Win entry points (#38648)
* Normalize Spack Win entrypoints Currently Spack has multiple entrypoints on Windows that in addition to differing from *nix implementations, differ from shell to shell on Windows. This is a bit confusing for new users and in general unnecessary. This PR adds a normal setup script for the batch shell while preserving the previous "click from file explorer for spack shell" behavior. Additionally adds a shell title to both powershell and cmd letting users know this is a Spack shell * remove doskeys
Diffstat (limited to 'share')
-rw-r--r--share/spack/setup-env.bat77
-rw-r--r--share/spack/setup-env.ps11
2 files changed, 78 insertions, 0 deletions
diff --git a/share/spack/setup-env.bat b/share/spack/setup-env.bat
new file mode 100644
index 0000000000..c3b91ece1f
--- /dev/null
+++ b/share/spack/setup-env.bat
@@ -0,0 +1,77 @@
+@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
+if not defined python_pf_ver (
+(for /f "delims=" %%F in ('where python.exe') do (
+ set "python_pf_ver=%%F"
+ goto :found_python
+ ) ) 2> NUL
+)
+:found_python
+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
+endlocal & (
+ set "SPACK_ROOT=%SPACK_ROOT%"
+ set "spackinstdir=%spackinstdir%"
+ set "py_path=%py_path%"
+ set "py_exe=%py_exe%"
+)
+
+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"
+)
+
+if not defined EDITOR (
+ set EDITOR=notepad
+)
+
+@echo **********************************************************************
+@echo ** Spack Package Manager
+@echo **********************************************************************
+
+IF "%1"=="" GOTO CONTINUE
+set
+GOTO:EOF
+
+:continue
+title Spack
+set PROMPT=[spack] %PROMPT%
diff --git a/share/spack/setup-env.ps1 b/share/spack/setup-env.ps1
index d67e39f85b..88f91f261d 100644
--- a/share/spack/setup-env.ps1
+++ b/share/spack/setup-env.ps1
@@ -60,5 +60,6 @@ function global:prompt
$pth = $(Convert-Path $(Get-Location)) | Split-Path -leaf
"[spack] PS $pth>"
}
+[system.console]::title = "Spack"
Pop-Location