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 1/5] 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" From eb841eed79d3a7ffcab0e6a9f1281c03224e5fef Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:34:33 -0800 Subject: [PATCH 2/5] Ensure that post-install.bat stdout/err is sent to install.log. --- installers-conda/resources/post-install.bat | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/installers-conda/resources/post-install.bat b/installers-conda/resources/post-install.bat index a45810e06d2..142b1e21471 100644 --- a/installers-conda/resources/post-install.bat +++ b/installers-conda/resources/post-install.bat @@ -1,11 +1,22 @@ @rem This script launches Spyder after install @echo off -if "%CI%"=="1" set no_launch_spyder=true +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 CI or silent mode, do not launch Spyder exit /b %errorlevel% +) else ( + @echo Launching Spyder after install completed. ) set mode=system @@ -17,6 +28,7 @@ for /F "tokens=*" %%i in ( ) do ( set shortcut=%%~fi ) +@echo shortcut = %shortcut% @rem Launch Spyder set tmpdir=%TMP%\spyder From c9410515648bbd4397ccd30ab82015795a1d0a4b Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:34:12 -0800 Subject: [PATCH 3/5] Do not launch Spyder if macOS pkg installer is run from command line. --- installers-conda/resources/post-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installers-conda/resources/post-install.sh b/installers-conda/resources/post-install.sh index a12cc1439be..1b6d15014c2 100755 --- a/installers-conda/resources/post-install.sh +++ b/installers-conda/resources/post-install.sh @@ -186,7 +186,7 @@ fi echo "*** Post install script for ${INSTALLER_NAME} complete" # ---- Launch Spyder -if [[ -n "$CI" || "$INSTALLER_UNATTENDED" == "1" ]]; then +if [[ -n "$CI" || "$INSTALLER_UNATTENDED" == "1" || "$COMMAND_LINE_INSTALL" == "1" ]]; then echo Installing in CI or batch mode, do not launch Spyder exit 0 fi From 2fe8ccd9dc6936758370b6512a78c3309477ed56 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:59:01 -0800 Subject: [PATCH 4/5] Appropriately trigger workflows on change of installer_test.sh --- .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 ++ 6 files changed, 11 insertions(+) diff --git a/.github/workflows/installers-conda.yml b/.github/workflows/installers-conda.yml index 0d3f7285804..36dfa3e6a56 100644 --- a/.github/workflows/installers-conda.yml +++ b/.github/workflows/installers-conda.yml @@ -7,6 +7,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 5e3bb9ce692..78a679138c9 100644 --- a/.github/workflows/test-files.yml +++ b/.github/workflows/test-files.yml @@ -18,6 +18,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -36,6 +37,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' workflow_call: diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 165d19f24ed..14e257c6e8b 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -18,6 +18,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -36,6 +37,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' workflow_call: diff --git a/.github/workflows/test-mac.yml b/.github/workflows/test-mac.yml index ef830498bcc..7ab9d5fa3a6 100644 --- a/.github/workflows/test-mac.yml +++ b/.github/workflows/test-mac.yml @@ -18,6 +18,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -36,6 +37,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' workflow_call: diff --git a/.github/workflows/test-remoteclient.yml b/.github/workflows/test-remoteclient.yml index e88989fe9d8..bf1ea453791 100644 --- a/.github/workflows/test-remoteclient.yml +++ b/.github/workflows/test-remoteclient.yml @@ -16,6 +16,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -32,6 +33,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' workflow_call: diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index 8a1f8fdd7a4..6ce2d71f1a9 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -18,6 +18,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' pull_request: branches: @@ -36,6 +37,7 @@ on: - '!.github/workflows/installers-conda.yml' - '!.github/workflows/build-subrepos.yml' - '!.github/workflows/purge-cache.yml' + - '!.github/scripts/installer_test.sh' workflow_call: From 3940d5d82e06d4fed8d5d6dd3e78cda51bf292f9 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:12:11 -0800 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Carlos Cordoba --- installers-conda/resources/post-install.bat | 2 +- installers-conda/resources/post-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installers-conda/resources/post-install.bat b/installers-conda/resources/post-install.bat index 142b1e21471..e3703b76d38 100644 --- a/installers-conda/resources/post-install.bat +++ b/installers-conda/resources/post-install.bat @@ -13,7 +13,7 @@ if "%INSTALLER_UNATTENDED%"=="1" set no_launch_spyder=true @echo INSTALLER_UNATTENDED = %INSTALLER_UNATTENDED% @echo no_launch_spyder = %no_launch_spyder% if defined no_launch_spyder ( - @echo Installing in CI or silent mode, do not launch Spyder + @echo Installing in silent mode, do not launch Spyder exit /b %errorlevel% ) else ( @echo Launching Spyder after install completed. diff --git a/installers-conda/resources/post-install.sh b/installers-conda/resources/post-install.sh index 1b6d15014c2..357a5faaa9e 100755 --- a/installers-conda/resources/post-install.sh +++ b/installers-conda/resources/post-install.sh @@ -187,7 +187,7 @@ echo "*** Post install script for ${INSTALLER_NAME} complete" # ---- Launch Spyder if [[ -n "$CI" || "$INSTALLER_UNATTENDED" == "1" || "$COMMAND_LINE_INSTALL" == "1" ]]; then - echo Installing in CI or batch mode, do not launch Spyder + echo Installing in batch mode, do not launch Spyder exit 0 fi