From 03f6be7ededfc63af9389f36f00669f635512a57 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 28 Apr 2025 12:56:31 -0700 Subject: [PATCH 1/4] Remove unnecessary script elements --- src/spyder_updater/gui/updater.py | 10 +++--- src/spyder_updater/scripts/install.bat | 50 +++----------------------- src/spyder_updater/scripts/install.sh | 46 +++++++----------------- 3 files changed, 22 insertions(+), 84 deletions(-) diff --git a/src/spyder_updater/gui/updater.py b/src/spyder_updater/gui/updater.py index 38076fc..c78d52a 100644 --- a/src/spyder_updater/gui/updater.py +++ b/src/spyder_updater/gui/updater.py @@ -399,10 +399,12 @@ def start_install(self): # Sub command if self._update_info.get("installation_script") is None: # Running the installation scripts - sub_cmd = [script_path, '-i', self.install_file] - if self.update_type != 'major': - # Update with conda - sub_cmd.extend(['-c', self.conda_exec, '-p', self.env_path]) + sub_cmd = [ + script_path, + '-i', self.install_file, + '-c', self.conda_exec, + '-p', self.env_path + ] if self.update_type == 'minor': # Rebuild runtime environment diff --git a/src/spyder_updater/scripts/install.bat b/src/spyder_updater/scripts/install.bat index 9fe4080..c0fa0e0 100644 --- a/src/spyder_updater/scripts/install.bat +++ b/src/spyder_updater/scripts/install.bat @@ -16,24 +16,9 @@ GOTO parse rem Enforce encoding chcp 65001>nul -echo. -echo ========================================================= -echo Updating Spyder -echo ========================================================= -echo. - call :wait_for_spyder_quit - -IF exist "%conda%" IF exist "%prefix%" ( - call :update_subroutine - call :launch_spyder - goto :exit -) - -IF exist "%install_file%" ( - call :install_subroutine - goto :exit -) +call :update_spyder +call :launch_spyder :exit exit %ERRORLEVEL% @@ -46,10 +31,10 @@ IF exist "%install_file%" ( timeout /t 1 /nobreak > nul goto loop ) - echo Spyder is quit. + echo Spyder has quit. goto :EOF -:update_subroutine +:update_spyder for %%C in ("%install_file%") do set installer_dir=%%~dpC pushd %installer_dir% @@ -81,30 +66,3 @@ IF exist "%install_file%" ( start "" /B "%shortcut_path%" goto :EOF - -:install_subroutine - echo Installing Spyder from: %install_file% - - rem Uninstall Spyder - for %%I in ("%prefix%\..\..") do set "conda_root=%%~fI" - - echo Install will proceed after the current Spyder version is uninstalled. - start %conda_root%\Uninstall-Spyder.exe - - rem Must wait for uninstaller to appear on tasklist - :wait_for_uninstall_start - tasklist /fi "ImageName eq Un_A.exe" /fo csv 2>NUL | find /i "Un_A.exe">NUL - IF "%ERRORLEVEL%"=="1" ( - timeout /t 1 /nobreak > nul - goto wait_for_uninstall_start - ) - echo Uninstall in progress... - - :wait_for_uninstall - timeout /t 1 /nobreak > nul - tasklist /fi "ImageName eq Un_A.exe" /fo csv 2>NUL | find /i "Un_A.exe">NUL - IF "%ERRORLEVEL%"=="0" goto wait_for_uninstall - echo Uninstall complete. - - start %install_file% - goto :EOF diff --git a/src/spyder_updater/scripts/install.sh b/src/spyder_updater/scripts/install.sh index f354cdf..cfac92c 100755 --- a/src/spyder_updater/scripts/install.sh +++ b/src/spyder_updater/scripts/install.sh @@ -10,6 +10,15 @@ while getopts "i:c:p:r" option; do done shift $(($OPTIND - 1)) +wait_for_spyder_quit(){ + while [[ $(pgrep spyder 2> /dev/null) ]]; do + echo "Waiting for Spyder to quit..." + sleep 1 + done + + echo "Spyder has quit." +} + update_spyder(){ # Unzip installer file pushd $(dirname $install_file) @@ -53,37 +62,6 @@ launch_spyder(){ fi } -install_spyder(){ - # First uninstall Spyder - uninstall_script="$prefix/../../uninstall-spyder.sh" - if [[ -f "$uninstall_script" ]]; then - echo "Uninstalling Spyder..." - echo "" - $uninstall_script - [[ $? > 0 ]] && return - fi - - # Run installer - [[ "$OSTYPE" = "darwin"* ]] && open $install_file || sh $install_file -} - -cat < /dev/null) ]]; do - echo "Waiting for Spyder to quit..." - sleep 1 -done - -echo "Spyder quit." - -if [[ -e "$conda" && -d "$prefix" ]]; then - update_spyder - launch_spyder -else - install_spyder -fi +wait_for_spyder_quit +update_spyder +launch_spyder From 4578b7db4954bb02372e6b66cd6f7efa69dd6ee9 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 28 Apr 2025 12:56:44 -0700 Subject: [PATCH 2/4] Add option to start Spyder after successful update. --- src/spyder_updater/gui/updater.py | 5 ++++- src/spyder_updater/scripts/install.bat | 3 ++- src/spyder_updater/scripts/install.sh | 5 +++-- src/spyder_updater/start.py | 8 +++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/spyder_updater/gui/updater.py b/src/spyder_updater/gui/updater.py index c78d52a..2697e4d 100644 --- a/src/spyder_updater/gui/updater.py +++ b/src/spyder_updater/gui/updater.py @@ -389,7 +389,7 @@ def _handle_error(self, error): # ---- Public API # ------------------------------------------------------------------------- - def start_install(self): + def start_install(self, start_spyder: bool): # Install script script_name = 'install.' + ('bat' if os.name == 'nt' else 'sh') script_path = str( @@ -409,6 +409,9 @@ def start_install(self): if self.update_type == 'minor': # Rebuild runtime environment sub_cmd.append('-r') + + if start_spyder: + sub_cmd.append("-s") else: # For testing script = self._update_info["installation_script"] diff --git a/src/spyder_updater/scripts/install.bat b/src/spyder_updater/scripts/install.bat index c0fa0e0..5018714 100644 --- a/src/spyder_updater/scripts/install.bat +++ b/src/spyder_updater/scripts/install.bat @@ -8,6 +8,7 @@ IF "%~1"=="-i" set install_file=%~2& SHIFT IF "%~1"=="-c" set conda=%~2& SHIFT IF "%~1"=="-p" set prefix=%~2& SHIFT If "%~1"=="-r" set rebuild=true +if "%~1"=="-s" set start_spyder=true SHIFT GOTO parse @@ -18,7 +19,7 @@ chcp 65001>nul call :wait_for_spyder_quit call :update_spyder -call :launch_spyder +if "%start_spyder%"=="true" call :launch_spyder :exit exit %ERRORLEVEL% diff --git a/src/spyder_updater/scripts/install.sh b/src/spyder_updater/scripts/install.sh index cfac92c..9d5d66d 100755 --- a/src/spyder_updater/scripts/install.sh +++ b/src/spyder_updater/scripts/install.sh @@ -1,11 +1,12 @@ #!/bin/bash -while getopts "i:c:p:r" option; do +while getopts "i:c:p:rs" option; do case "$option" in (i) install_file=$OPTARG ;; (c) conda=$OPTARG ;; (p) prefix=$OPTARG ;; (r) rebuild=true ;; + (s) start_spyder=true ;; esac done shift $(($OPTIND - 1)) @@ -64,4 +65,4 @@ launch_spyder(){ wait_for_spyder_quit update_spyder -launch_spyder +[[ "$start_spyder" == "true" ]] && launch_spyder diff --git a/src/spyder_updater/start.py b/src/spyder_updater/start.py index c7cc635..517aff9 100644 --- a/src/spyder_updater/start.py +++ b/src/spyder_updater/start.py @@ -32,6 +32,12 @@ def main(): type=argparse.FileType(), help="Path to file that has the info to update Spyder" ) + parser.add_argument( + "--start-spyder", + action="store_true", + default=False, + help="Start spyder after successfully installing the update." + ) parser.add_argument( "--version", action="store_true", @@ -67,7 +73,7 @@ def main(): # Instantiate updater and start installation updater = Updater(update_info) - updater.start_install() + updater.start_install(args.start_spyder) updater.show() # Start the Qt event loop From 5b07c62ded4074320432d1b8cfe616278d7b9ea5 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 28 Apr 2025 11:02:03 -0700 Subject: [PATCH 3/4] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d66aa35..c00e719 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ It provides a graphical interface and the necessary scripts to perform the updat You can check how the updater looks by running the following command from the root directory of this repo: ```bash -python spyder_updater/start-update.py --update-info-file tests/info-success.json +python src/spyder_updater/start.py --update-info-file src/tests/info-success.json ``` From 31881d5682c5cd5f8c98b1db1943379085ba6df2 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:24:07 -0700 Subject: [PATCH 4/4] Update to setup-micromamba@v2. Resolves warnings "Failed to restore: Cache service responded with 422" and "This legacy service is shutting down, effective April 15, 2025. Migrate to the new service ASAP" --- .github/workflows/build-updater.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-updater.yml b/.github/workflows/build-updater.yml index b9badc9..ec8a637 100644 --- a/.github/workflows/build-updater.yml +++ b/.github/workflows/build-updater.yml @@ -49,7 +49,7 @@ jobs: detached: true - name: Setup Build Environment - uses: mamba-org/setup-micromamba@v1 + uses: mamba-org/setup-micromamba@v2 with: condarc: | conda_build: