Skip to content

Commit

Permalink
handle shortcus with --shortcuts-only now
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Nov 25, 2021
1 parent 3a4d2b3 commit 04351c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 6 additions & 7 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'
Expand Down
13 changes: 12 additions & 1 deletion constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,25 @@ 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),
('@NSIS_DIR@', NSIS_DIR),
('@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})'
Expand Down

0 comments on commit 04351c1

Please sign in to comment.