Skip to content

Commit

Permalink
mark as incompatible, not disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Dec 20, 2023
1 parent 6ea01e1 commit 858371a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def verify(info):
sys.exit(
f"Environment names (keys in 'extra_envs') cannot contain any of {disallowed}. "
f"You tried to use: {env_name}"
)
)
for key, value in env_data.items():
if key not in _EXTRA_ENVS_SCHEMA:
sys.exit(f"Key '{key}' not supported in 'extra_envs'.")
Expand Down
10 changes: 5 additions & 5 deletions constructor/fcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def getsize(filename):

def warn_menu_packages_missing(precs, menu_packages):
all_names = {prec.name for prec in precs}
for name in menu_packages:
for name in (menu_packages or ()):
if name not in all_names:
logger.warning("no such package (in menu_packages): %s", name)

Expand Down Expand Up @@ -236,7 +236,7 @@ def _precs_from_environment(environment, input_dir):


def _solve_precs(name, version, download_dir, platform, channel_urls=(), channels_remap=(),
specs=(), exclude=(), menu_packages=(), environment=None, environment_file=None,
specs=(), exclude=(), menu_packages=None, environment=None, environment_file=None,
verbose=True, conda_exe="conda.exe", extra_env=False, input_dir=""):
# Add python to specs, since all installers need a python interpreter. In the future we'll
# probably want to add conda too.
Expand Down Expand Up @@ -376,7 +376,7 @@ def _fetch_precs(precs, download_dir, transmute_file_type=''):


def _main(name, version, download_dir, platform, channel_urls=(), channels_remap=(), specs=(),
exclude=(), menu_packages=(), ignore_duplicate_files=True, environment=None,
exclude=(), menu_packages=None, ignore_duplicate_files=True, environment=None,
environment_file=None, verbose=True, dry_run=False, conda_exe="conda.exe",
transmute_file_type='', extra_envs=None, check_path_spaces=True, input_dir=""):
precs = _solve_precs(
Expand Down Expand Up @@ -408,7 +408,7 @@ def _main(name, version, download_dir, platform, channel_urls=(), channels_remap
channels_remap=env_config.get("channels_remap", channels_remap),
specs=env_config.get("specs", ()),
exclude=env_config.get("exclude", exclude),
menu_packages=env_config.get("menu_packages", ()),
menu_packages=env_config.get("menu_packages"),
environment=env_config.get("environment"),
environment_file=env_config.get("environment_file"),
verbose=verbose,
Expand Down Expand Up @@ -462,7 +462,7 @@ def main(info, verbose=True, dry_run=False, conda_exe="conda.exe"):
channels_remap = info.get('channels_remap', ())
specs = info.get("specs", ())
exclude = info.get("exclude", ())
menu_packages = info.get("menu_packages", ())
menu_packages = info.get("menu_packages")
ignore_duplicate_files = info.get("ignore_duplicate_files", True)
environment = info.get("environment", None)
environment_file = info.get("environment_file", None)
Expand Down
8 changes: 6 additions & 2 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,19 @@ test -d ~/.conda || mkdir -p ~/.conda >/dev/null 2>/dev/null || test -d ~/.conda

printf "\nInstalling base environment...\n\n"

#if enable_shortcuts
#if enable_shortcuts == "true"
if [ "$SKIP_SHORTCUTS" = "1" ]; then
shortcuts="--no-shortcuts"
else
shortcuts="__SHORTCUTS__"
fi
#else
#endif
#if enable_shortcuts == "false"
shortcuts="--no-shortcuts"
#endif
#if enable_shortcuts == "incompatible"
shortcuts=""
#endif

# shellcheck disable=SC2086
CONDA_ROOT_PREFIX="$PREFIX" \
Expand Down
4 changes: 2 additions & 2 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
exe_name == "micromamba" or Version(exe_version) < Version("23.11.0")
):
logger.warning("conda-standalone 23.11.0 or above is required for shortcuts on Unix.")
info['_enable_shortcuts'] = False
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_info", {}).values()
for env in info.get("extra_envs", {}).values()
)
)

Expand Down
3 changes: 2 additions & 1 deletion constructor/osx/check_shortcuts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ PREFIX=$(cd "$PREFIX"; pwd)
# during run_installation.sh
# If it doesn't exist, it means that this script never ran
# due to (A) the user deselected the option, or (B) the installer
# was created with menu_packages=[], which disables shortcuts altogether
# was created with menu_packages=[], which disables shortcuts altogether,
# or (C) the installer was created with an incompatible --conda-exe.
touch "$PREFIX/pkgs/user_wants_shortcuts"
4 changes: 3 additions & 1 deletion constructor/osx/run_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ CONDA_EXEC="$PREFIX/conda.exe"

# Check whether the user wants shortcuts or not
# See check_shortcuts.sh script for details
if [[ -f "$PREFIX/pkgs/user_wants_shortcuts" ]]; then
if [[ -f "$PREFIX/pkgs/user_wants_shortcuts" ]]; then # this implies ENABLE_SHORTCUTS==true
shortcuts="__SHORTCUTS__"
elif [[ "__ENABLE_SHORTCUTS__" == "incompatible" ]]; then
shortcuts=""
else
shortcuts="--no-shortcuts"
fi
Expand Down
7 changes: 4 additions & 3 deletions constructor/osxpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def modify_xml(xml_path, info):
path_choice.set('visible', 'false')
path_choice.set('title', 'Apply {}'.format(info['name']))
path_choice.set('enabled', 'false')
elif ident.endswith('shortcuts') and info["_enable_shortcuts"]:
elif ident.endswith('shortcuts'):
# Show this option if menu_packages was set to a non-empty value
# or if the option was not set at all. We don't show the option
# menu_packages was set to an empty list!
Expand All @@ -228,7 +228,7 @@ def modify_xml(xml_path, info):
menu_packages = info.get("menu_packages")
if menu_packages is None:
menu_packages = []
for extra_env in info.get("_extra_envs_info", {}).values():
for extra_env in info.get("extra_envs", {}).values():
menu_packages += extra_env.get("menu_packages", [])
if menu_packages:
descr += f" ({', '.join(menu_packages)})"
Expand Down Expand Up @@ -324,6 +324,7 @@ def move_script(src, dst, info, ensure_shebang=False, user_script_type=None):
'PRE_OR_POST': user_script_type or '__PRE_OR_POST__',
'CONSTRUCTOR_VERSION': info['CONSTRUCTOR_VERSION'],
'SHORTCUTS': shortcuts_flags(info),
'ENABLE_SHORTCUTS': str(info['_enable_shortcuts']).lower(),
'REGISTER_ENVS': str(info.get("register_envs", True)).lower(),
}
data = preprocess(data, ppd)
Expand Down Expand Up @@ -525,7 +526,7 @@ def create(info, verbose=False):
names.append('user_pre_install')

# pre-3. Enable or disable shortcuts creation
if info['_enable_shortcuts']:
if info['_enable_shortcuts'] is True:
pkgbuild_script('shortcuts', info, 'check_shortcuts.sh')
names.append('shortcuts')

Expand Down
2 changes: 1 addition & 1 deletion constructor/shar.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_header(conda_exec, tarball, info):
ppd['initialize_conda'] = info.get('initialize_conda', True)
ppd['initialize_by_default'] = info.get('initialize_by_default', False)
ppd['has_conda'] = info['_has_conda']
ppd['enable_shortcuts'] = info['_enable_shortcuts']
ppd['enable_shortcuts'] = str(info['_enable_shortcuts']).lower()
ppd['check_path_spaces'] = info.get("check_path_spaces", True)
install_lines = list(add_condarc(info))
# Needs to happen first -- can be templated
Expand Down
4 changes: 2 additions & 2 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def setup_envs_commands(info, dir_path):
conda_meta=join("$INSTDIR", "envs", env_name, "conda-meta"),
history_abspath=join(dir_path, "envs", env_name, "conda-meta", "history"),
channels=",".join(get_final_channels(channel_info)),
shortcuts=shortcuts_flags(env_info),
shortcuts=shortcuts_flags(env_info, conda_exe=info.get("_conda_exe")),
register_envs=str(info.get("register_envs", True)).lower(),
).splitlines()

Expand Down Expand Up @@ -275,7 +275,7 @@ def make_nsi(info, dir_path, extra_files=None, temp_extra_files=None):
join('%ALLUSERSPROFILE%', name.lower())),
'PRE_INSTALL_DESC': info['pre_install_desc'],
'POST_INSTALL_DESC': info['post_install_desc'],
'ENABLE_SHORTCUTS': "yes" if info['_enable_shortcuts'] else "no",
'ENABLE_SHORTCUTS': "yes" if info['_enable_shortcuts'] is True else "no",
'SHOW_REGISTER_PYTHON': "yes" if info.get("register_python", True) else "no",
'SHOW_ADD_TO_PATH': "yes" if info.get("initialize_conda", True) else "no",
'OUTFILE': info['_outpath'],
Expand Down

0 comments on commit 858371a

Please sign in to comment.