From 04351c133bf0c3dcf004ab689131a292b2459eb7 Mon Sep 17 00:00:00 2001 From: Jaime RGP Date: Thu, 25 Nov 2021 17:41:11 +0100 Subject: [PATCH] handle shortcus with --shortcuts-only now --- constructor/nsis/main.nsi.tmpl | 13 ++++++------- constructor/winexe.py | 13 ++++++++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index e08536c6c..5ce046f0d 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -881,9 +881,7 @@ Section "Install" SetDetailsPrint TextOnly DetailPrint "Setting up the base environment ..." - # Need to use `--no-shortcuts` because the shortcuts are created in the following steps. The reason is that `conda install` - # doesn't support `menu_packages` entry of `construct.yaml` and will therefore create possible shorcuts - nsExec::ExecToLog '"$INSTDIR\_conda.exe" install --offline -yp "$INSTDIR" --file "$INSTDIR\pkgs\env.txt" --no-shortcuts' + nsExec::ExecToLog '"$INSTDIR\_conda.exe" install --offline -yp "$INSTDIR" --file "$INSTDIR\pkgs\env.txt" @SHORTCUTS@' Pop $0 SetDetailsPrint both @@ -900,10 +898,11 @@ Section "Install" SetOutPath "$INSTDIR\conda-meta" File __CONDA_HISTORY__ - DetailPrint "Creating @NAME@ menus..." - push '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --make-menus @MENU_PKGS@' - push 'Failed to create menus' - call AbortRetryNSExecWait + # Not needed anymore thanks to the new --shortcuts-only arg, set above in @SHORTCUTS@ + # DetailPrint "Creating @NAME@ menus..." + # push '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --make-menus @MENU_PKGS@' + # push 'Failed to create menus' + # call AbortRetryNSExecWait push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs' push 'Failed to initialize Anaconda directories' diff --git a/constructor/winexe.py b/constructor/winexe.py index 07d5493f3..38f991761 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -115,6 +115,17 @@ def make_nsi(info, dir_path): approx_pkgs_size_kb = int( math.ceil(info.get('_approx_pkgs_size', 0) / 1000)) + menu_packages = info.get("menu_packages") + if menu_packages is None: + # not set: we create all shortcuts (default behaviour) + shortcuts = "" + elif menu_packages: + # set and populated: we only create shortcuts for some + shortcuts = ' '.join([f'--shortcuts-only="{pkg}"' for pkg in menu_packages]) + else: + # set but empty: disable all shortcuts + shortcuts = "--no-shortcuts" + # these are unescaped (and unquoted) for key, value in [ ('@NAME@', name), @@ -122,7 +133,7 @@ def make_nsi(info, dir_path): ('@BITS@', str(arch)), ('@PKG_COMMANDS@', '\n '.join(pkg_commands(download_dir, dists))), ('@WRITE_CONDARC@', '\n '.join(add_condarc(info))), - ('@MENU_PKGS@', ' '.join(info.get('menu_packages', []))), + ('@SHORTCUTS@', shortcuts), ('@SIZE@', str(approx_pkgs_size_kb)), ('@UNINSTALL_NAME@', info.get('uninstall_name', '${NAME} ${VERSION} (Python ${PYVERSION} ${ARCH})'