From c51d488756387d8eaaa7f733d19c0b5d98e68e1b Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 20 Dec 2024 08:45:24 -0600 Subject: [PATCH] pre-initialize _enable_shortcuts based on configuration --- constructor/main.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/constructor/main.py b/constructor/main.py index e4d8c8975..b60d77e47 100644 --- a/constructor/main.py +++ b/constructor/main.py @@ -187,26 +187,27 @@ def main_build(dir_path, output_dir='.', platform=cc_platform, else: env_config[config_key] = value - if exe_type is None or exe_version is None: - logger.warning( - "Could not identify conda-standalone / micromamba version. " - "Will assume it is compatible with shortcuts." + # Installers will provide shortcut options and features only if the user + # didn't opt-out by setting every `menu_packages` item to an empty list + info['_enable_shortcuts'] = bool( + info.get("menu_packages", True) + or any( + env.get("menu_packages", True) + for env in info.get("extra_envs", {}).values() ) - elif sys.platform != "win32" and ( - exe_type != StandaloneExe.CONDA or (exe_version and exe_version < Version("23.11.0")) - ): - logger.warning("conda-standalone 23.11.0 or above is required for shortcuts on Unix.") - info['_enable_shortcuts'] = "incompatible" - else: - # Installers will provide shortcut options and features only if the user - # didn't opt-out by setting every `menu_packages` item to an empty list - info['_enable_shortcuts'] = bool( - info.get("menu_packages", True) - or any( - env.get("menu_packages", True) - for env in info.get("extra_envs", {}).values() + ) + + if info['_enable_shortcuts']: + if exe_type is None or exe_version is None: + logger.warning( + "Could not identify conda-standalone / micromamba version. " + "Will assume it is compatible with shortcuts." ) - ) + elif sys.platform != "win32" and ( + exe_type != StandaloneExe.CONDA or (exe_version and exe_version < Version("23.11.0")) + ): + logger.warning("conda-standalone 23.11.0 or above is required for shortcuts on Unix.") + info['_enable_shortcuts'] = "incompatible" # Add --no-rc option to CONDA_EXE command so that existing # .condarc files do not pollute the installation process.