From e6082f9eddd563101b8098342b965a30832d21df Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:16:25 -0800 Subject: [PATCH] Do not launch Spyder if installing in CI or batch/silent mode. With conda/constructor#885, batch/silent mode installs will automatically set INSTALLER_UNATTENDED environment variable accessible by user scripts. Until the next constructor version (>3.9.3) users may set either CI=1 or INSTALLER_UNATTENDED=1 at the commandline. --- installers-conda/resources/post-install.bat | 14 +++++++++++--- installers-conda/resources/post-install.sh | 5 ++++- installers-conda/resources/pre-install.bat | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/installers-conda/resources/post-install.bat b/installers-conda/resources/post-install.bat index fd48e6c6e53..a45810e06d2 100644 --- a/installers-conda/resources/post-install.bat +++ b/installers-conda/resources/post-install.bat @@ -1,17 +1,24 @@ -rem This script launches Spyder after install +@rem This script launches Spyder after install @echo off +if "%CI%"=="1" set no_launch_spyder=true +if "%INSTALLER_UNATTENDED%"=="1" set no_launch_spyder=true +if defined no_launch_spyder ( + @echo Installing in CI or silent mode, do not launch Spyder + exit /b %errorlevel% +) + set mode=system if exist "%PREFIX%\.nonadmin" set mode=user -rem Get shortcut path +@rem Get shortcut path for /F "tokens=*" %%i in ( '%PREFIX%\python %PREFIX%\Scripts\menuinst_cli.py shortcut --mode=%mode%' ) do ( set shortcut=%%~fi ) -rem Launch Spyder +@rem Launch Spyder set tmpdir=%TMP%\spyder set launch_script=%tmpdir%\launch_script.bat @@ -21,6 +28,7 @@ echo @echo off echo :loop echo tasklist /fi "ImageName eq Spyder-*" /fo csv 2^>NUL ^| findstr /r "Spyder-.*Windows-x86_64.exe"^>NUL echo if "%%errorlevel%%"=="0" ^( +echo @rem Installer is still running echo timeout /t 1 /nobreak ^> nul echo goto loop echo ^) else ^( diff --git a/installers-conda/resources/post-install.sh b/installers-conda/resources/post-install.sh index ee56875b5b3..a12cc1439be 100755 --- a/installers-conda/resources/post-install.sh +++ b/installers-conda/resources/post-install.sh @@ -186,7 +186,10 @@ fi echo "*** Post install script for ${INSTALLER_NAME} complete" # ---- Launch Spyder -[[ -n "$CI" ]] && exit 0 # Running in CI, don't launch Spyder +if [[ -n "$CI" || "$INSTALLER_UNATTENDED" == "1" ]]; then + echo Installing in CI or batch mode, do not launch Spyder + exit 0 +fi echo "Launching Spyder now..." if [[ "$OSTYPE" == "darwin"* ]]; then diff --git a/installers-conda/resources/pre-install.bat b/installers-conda/resources/pre-install.bat index 83cf5084652..ad3941c2b68 100644 --- a/installers-conda/resources/pre-install.bat +++ b/installers-conda/resources/pre-install.bat @@ -1,4 +1,4 @@ -rem Mark as conda-based-app +@rem Mark as conda-based-app set menudir=%PREFIX%\envs\spyder-runtime\Menu if not exist "%menudir%" mkdir "%menudir%" echo. > "%menudir%\conda-based-app"