From 07e8f52d134b3f6abf91324fae1f071687a13293 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Thu, 7 Nov 2024 14:26:21 -0500 Subject: [PATCH] Backport PR #22876 on branch 6.x (PR: Do not launch Spyder if installing in CI or batch/silent mode (Installers)) (#22893) --- .github/workflows/installers-conda.yml | 1 + .github/workflows/test-files.yml | 2 ++ .github/workflows/test-linux.yml | 2 ++ .github/workflows/test-mac.yml | 2 ++ .github/workflows/test-remoteclient.yml | 2 ++ .github/workflows/test-win.yml | 2 ++ installers-conda/resources/post-install.bat | 26 ++++++++++++++++++--- installers-conda/resources/post-install.sh | 5 +++- installers-conda/resources/pre-install.bat | 2 +- 9 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/installers-conda.yml b/.github/workflows/installers-conda.yml index aadc6874dc3..35321d3c07b 100644 --- a/.github/workflows/installers-conda.yml +++ b/.github/workflows/installers-conda.yml @@ -6,6 +6,7 @@ on: paths: - 'installers-conda/**' - '.github/workflows/installers-conda.yml' + - '.github/scripts/installer_test.sh' - 'requirements/*.yml' - 'MANIFEST.in' diff --git a/.github/workflows/test-files.yml b/.github/workflows/test-files.yml index 7fb41afdccc..2f1e7fa7790 100644 --- a/.github/workflows/test-files.yml +++ b/.github/workflows/test-files.yml @@ -17,6 +17,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -34,6 +35,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' workflow_dispatch: diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 17fbf99e2c6..3ad8353023c 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -17,6 +17,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -34,6 +35,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' workflow_dispatch: inputs: diff --git a/.github/workflows/test-mac.yml b/.github/workflows/test-mac.yml index cddf1219092..190758c8ce4 100644 --- a/.github/workflows/test-mac.yml +++ b/.github/workflows/test-mac.yml @@ -17,6 +17,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -34,6 +35,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' workflow_dispatch: inputs: diff --git a/.github/workflows/test-remoteclient.yml b/.github/workflows/test-remoteclient.yml index f09063cf61b..52f80abf233 100644 --- a/.github/workflows/test-remoteclient.yml +++ b/.github/workflows/test-remoteclient.yml @@ -15,6 +15,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -30,6 +31,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' workflow_dispatch: inputs: diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index b04daa237e2..1a7c4423878 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -17,6 +17,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -34,6 +35,7 @@ on: - '!installers-conda/**' - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' + - '!.github/scripts/installer_test.sh' workflow_dispatch: inputs: diff --git a/installers-conda/resources/post-install.bat b/installers-conda/resources/post-install.bat index fd48e6c6e53..e3703b76d38 100644 --- a/installers-conda/resources/post-install.bat +++ b/installers-conda/resources/post-install.bat @@ -1,17 +1,36 @@ -rem This script launches Spyder after install +@rem This script launches Spyder after install @echo off +call :redirect 2>&1 >> %PREFIX%\install.log + +:redirect +@echo Environment Variables: +set + +if defined CI set no_launch_spyder=true +if "%INSTALLER_UNATTENDED%"=="1" set no_launch_spyder=true +@echo CI = %CI% +@echo INSTALLER_UNATTENDED = %INSTALLER_UNATTENDED% +@echo no_launch_spyder = %no_launch_spyder% +if defined no_launch_spyder ( + @echo Installing in silent mode, do not launch Spyder + exit /b %errorlevel% +) else ( + @echo Launching Spyder after install completed. +) + 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 ) +@echo shortcut = %shortcut% -rem Launch Spyder +@rem Launch Spyder set tmpdir=%TMP%\spyder set launch_script=%tmpdir%\launch_script.bat @@ -21,6 +40,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..357a5faaa9e 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" || "$COMMAND_LINE_INSTALL" == "1" ]]; then + echo Installing in 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"