diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index 0dd0f7422..f4af69c19 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -911,12 +911,6 @@ Section "Install" SetOutPath "$INSTDIR\conda-meta" File __CONDA_HISTORY__ - # 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' call AbortRetryNSExecWait diff --git a/constructor/osxpkg.py b/constructor/osxpkg.py index 93f385dba..9e283e617 100644 --- a/constructor/osxpkg.py +++ b/constructor/osxpkg.py @@ -5,7 +5,7 @@ import xml.etree.ElementTree as ET import constructor.preconda as preconda -from constructor.utils import add_condarc, get_final_channels, rm_rf +from constructor.utils import add_condarc, get_final_channels, rm_rf, shortcuts_flags OSX_DIR = join(dirname(__file__), "osx") @@ -143,14 +143,7 @@ def move_script(src, dst, info): data = data.replace('__NAME__', info['name']) data = data.replace('__CHANNELS__', ','.join(get_final_channels(info))) data = data.replace('__WRITE_CONDARC__', '\n'.join(add_condarc(info))) - - if info.get("menu_packages"): - data = data.replace( - '__SHORTCUTS__', - " ".join([f"--shortcuts-only={pkg.strip()}" for pkg in info['menu_packages']]) - ) - else: - data = data.replace('__SHORTCUTS__', "") + data = data.replace('__SHORTCUTS__', shortcuts_flags(info)) with open(dst, 'w') as fo: fo.write(data) diff --git a/constructor/shar.py b/constructor/shar.py index d08612541..1d0e03e4e 100644 --- a/constructor/shar.py +++ b/constructor/shar.py @@ -16,7 +16,7 @@ from .construct import ns_platform from .preconda import files as preconda_files, write_files as preconda_write_files from .utils import add_condarc, filename_dist, fill_template, hash_files, preprocess, \ - read_ascii_only, get_final_channels + read_ascii_only, get_final_channels, shortcuts_flags THIS_DIR = dirname(__file__) @@ -72,15 +72,11 @@ def get_header(conda_exec, tarball, info): 'INSTALL_COMMANDS': '\n'.join(install_lines), 'CHANNELS': ','.join(get_final_channels(info)), 'pycache': '__pycache__', + 'SHORTCUTS': shortcuts_flags(info), } if has_license: replace['LICENSE'] = read_ascii_only(info['license_file']) - if info.get("menu_packages"): - replace['SHORTCUTS'] = " ".join([f"--shortcuts-only={pkg.strip()}" for pkg in info['menu_packages']]) - else: - replace['SHORTCUTS'] = "" - data = read_header_template() data = preprocess(data, ppd) data = fill_template(data, replace) diff --git a/constructor/utils.py b/constructor/utils.py index 7ede63b57..18300c537 100644 --- a/constructor/utils.py +++ b/constructor/utils.py @@ -175,3 +175,18 @@ def yield_lines(path): if not line or line.startswith('#'): continue yield line + + +def shortcuts_flags(info): + 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" + + return shortcuts \ No newline at end of file diff --git a/constructor/winexe.py b/constructor/winexe.py index 72313ad52..20776b97f 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -18,7 +18,7 @@ from .imaging import write_images from .preconda import write_files as preconda_write_files from .utils import (filename_dist, fill_template, make_VIProductVersion, - preprocess, add_condarc, get_final_channels) + preprocess, add_condarc, get_final_channels, shortcuts_flags) THIS_DIR = abspath(dirname(__file__)) NSIS_DIR = join(THIS_DIR, 'nsis') @@ -115,17 +115,6 @@ 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), @@ -133,7 +122,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))), - ('@SHORTCUTS@', shortcuts), + ('@SHORTCUTS@', shortcuts_flags(info)), ('@SIZE@', str(approx_pkgs_size_kb)), ('@UNINSTALL_NAME@', info.get('uninstall_name', '${NAME} ${VERSION} (Python ${PYVERSION} ${ARCH})'