Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
15 changes: 10 additions & 5 deletions src/spyder_updater/gui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -399,14 +399,19 @@ 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
sub_cmd.append('-r')

if start_spyder:
sub_cmd.append("-s")
else:
# For testing
script = self._update_info["installation_script"]
Expand Down
51 changes: 5 additions & 46 deletions src/spyder_updater/scripts/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,24 +17,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
if "%start_spyder%"=="true" call :launch_spyder

:exit
exit %ERRORLEVEL%
Expand All @@ -46,10 +32,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%

Expand Down Expand Up @@ -81,30 +67,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
49 changes: 14 additions & 35 deletions src/spyder_updater/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#!/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))

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)
Expand Down Expand Up @@ -53,37 +63,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 <<EOF
=========================================================
Updating Spyder
=========================================================

EOF

while [[ $(pgrep spyder 2> /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
[[ "$start_spyder" == "true" ]] && launch_spyder
8 changes: 7 additions & 1 deletion src/spyder_updater/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down