diff --git a/installers-conda/build_installers.py b/installers-conda/build_installers.py index ae3c464b226..8d91559bd83 100644 --- a/installers-conda/build_installers.py +++ b/installers-conda/build_installers.py @@ -135,10 +135,10 @@ indent4 = partial(indent, prefix=" ") base_specs = { - "python": f"={PY_VER}", + "python": "=3.11.9", "conda": "=24.5.0", "menuinst": "=2.1.0", - "mamba": "", + "mamba": "=1.5.8", } rt_specs = { "python": f"={PY_VER}", diff --git a/spyder/plugins/updatemanager/scripts/install.bat b/spyder/plugins/updatemanager/scripts/install.bat index 39494e5be94..9587d0ce011 100644 --- a/spyder/plugins/updatemanager/scripts/install.bat +++ b/spyder/plugins/updatemanager/scripts/install.bat @@ -7,6 +7,8 @@ IF "%~1"=="" GOTO endparse 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 + SHIFT GOTO parse :endparse @@ -56,10 +58,19 @@ exit %ERRORLEVEL% pushd %installer_dir% echo Updating Spyder base environment... - %conda% update -n base -y --file conda-base-win-64.lock - - echo Updating Spyder runtime environment... - %conda% update -p %prefix% -y --file conda-runtime-win-64.lock + %conda% update --name base --yes --file conda-base-win-64.lock + + if "%rebuild%"=="true" ( + echo Rebuilding Spyder runtime environment... + %conda% remove --prefix %prefix% --all --yes + mkdir %prefix%\Menu + echo. > "%prefix%\Menu\conda-based-app" + set conda_cmd=create + ) else ( + echo Updating Spyder runtime environment... + set conda_cmd=update + ) + %conda% %conda_cmd% --prefix %prefix% --yes --file conda-runtime-win-64.lock echo Cleaning packages and temporary files... %conda% clean --yes --packages --tempfiles %prefix% diff --git a/spyder/plugins/updatemanager/scripts/install.sh b/spyder/plugins/updatemanager/scripts/install.sh index 4e281301c9a..f06024eedcc 100755 --- a/spyder/plugins/updatemanager/scripts/install.sh +++ b/spyder/plugins/updatemanager/scripts/install.sh @@ -2,11 +2,12 @@ unset HISTFILE # Do not write to history with interactive shell -while getopts "i:c:p:" option; do +while getopts "i:c:p:r" option; do case "$option" in (i) install_file=$OPTARG ;; (c) conda=$OPTARG ;; (p) prefix=$OPTARG ;; + (r) rebuild=true ;; esac done shift $(($OPTIND - 1)) @@ -20,10 +21,19 @@ update_spyder(){ [[ "$(arch)" = "arm64" ]] && os=${os}-arm64 || os=${os}-64 echo "Updating Spyder base environment..." - $conda update -n base -y --file "conda-base-${os}.lock" - - echo "Updating Spyder runtime environment..." - $conda update -p $prefix -y --file "conda-runtime-${os}.lock" + $conda update --name base --yes --file "conda-base-${os}.lock" + + if [[ -n "$rebuild" ]]; then + echo "Rebuilding Spyder runtime environment..." + $conda remove --prefix $prefix --all --yes + mkdir -p $prefix/Menu + touch $prefix/Menu/conda-based-app + conda_cmd=create + else + echo "Updating Spyder runtime environment..." + conda_cmd=update + fi + $conda $conda_cmd --prefix $prefix --yes --file "conda-runtime-${os}.lock" echo "Cleaning packages and temporary files..." $conda clean --yes --packages --tempfiles $prefix diff --git a/spyder/plugins/updatemanager/widgets/update.py b/spyder/plugins/updatemanager/widgets/update.py index 8fcb9401760..c55265e9bb1 100644 --- a/spyder/plugins/updatemanager/widgets/update.py +++ b/spyder/plugins/updatemanager/widgets/update.py @@ -133,6 +133,9 @@ def __init__(self, parent): self.installer_path = None self.installer_size_path = None + # Type of Spyder update. It can be "major", "minor" or "micro" + self.update_type = None + # ---- General def set_status(self, status=NO_STATUS): @@ -230,12 +233,16 @@ def _process_check_update(self): def _set_installer_path(self): """Set the temp file path for the downloaded installer.""" - major_update = ( - parse(__version__).major < parse(self.latest_release).major - ) + if parse(__version__).major < parse(self.latest_release).major: + self.update_type = 'major' + elif parse(__version__).minor < parse(self.latest_release).minor: + self.update_type = 'minor' + else: + self.update_type = 'micro' + mach = platform.machine().lower().replace("amd64", "x86_64") - if major_update or not is_conda_based_app(): + if self.update_type == 'major' or not is_conda_based_app(): if os.name == 'nt': plat, ext = 'Windows', 'exe' if sys.platform == 'darwin': @@ -250,6 +257,8 @@ def _set_installer_path(self): self.installer_path = osp.join(dirname, fname) self.installer_size_path = osp.join(dirname, "size") + logger.info(f"Update type: {self.update_type}") + # ---- Download Update def _verify_installer_path(self): @@ -259,9 +268,14 @@ def _verify_installer_path(self): ): with open(self.installer_size_path, "r") as f: size = int(f.read().strip()) - return size == osp.getsize(self.installer_path) + + update_downloaded = size == osp.getsize(self.installer_path) else: - return False + update_downloaded = False + + logger.debug(f"Update already downloaded: {update_downloaded}") + + return update_downloaded def start_update(self): """ @@ -428,10 +442,14 @@ def start_install(self): # Sub command sub_cmd = [tmpscript_path, '-i', self.installer_path] - if self.installer_path.endswith('.zip'): + if self.update_type != 'major': # Update with conda sub_cmd.extend(['-c', find_conda(), '-p', sys.prefix]) + if self.update_type == 'minor': + # Rebuild runtime environment + sub_cmd.append('-r') + # Final command assembly if os.name == 'nt': cmd = ['start', '"Update Spyder"'] + sub_cmd @@ -456,6 +474,8 @@ def start_install(self): cmd = [program['cmd'], program['exe-opt']] + sub_cmd break + logger.debug(f"""Update command: "{' '.join(cmd)}" """) + subprocess.Popen(' '.join(cmd), shell=True)