Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cross-platform support for the new menuinst #474

Merged
merged 118 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
aee42a4
support alphas and other non-int minor versions
jaimergp Nov 20, 2021
45648b9
act on .version
jaimergp Nov 20, 2021
1539d90
fix conda version handling again
jaimergp Nov 20, 2021
4cbe932
add shortcuts handling on linux / macos
jaimergp Nov 21, 2021
006c584
change how --shortcuts-only is set
jaimergp Nov 22, 2021
f882d79
handle shortcus with --shortcuts-only now
jaimergp Nov 25, 2021
9fc8f95
simplify shortcut flags generation
jaimergp Mar 25, 2022
6d94530
conda-standalone always available as $PREFIX/_conda.exe
jaimergp Mar 25, 2022
0f86922
revert accidental error on rebase
jaimergp Mar 25, 2022
a8bd12c
make shortcuts optional on windows again
jaimergp Mar 25, 2022
76c826b
Merge remote-tracking branch 'upstream/main' into menuinst-cep
jaimergp Sep 15, 2022
710a658
rework some options
jaimergp Sep 15, 2022
34019a5
fix macro conditional
jaimergp Sep 16, 2022
46d814e
ensure conda is in base env for extra_envs so we can remove the has_c…
jaimergp Sep 16, 2022
d6e5b98
update script path
jaimergp Sep 16, 2022
4a1fe01
escape curly braces
jaimergp Sep 16, 2022
5332f83
render docs
jaimergp Sep 16, 2022
b270777
fix quotes
jaimergp Sep 16, 2022
9703908
adjust cli syntax
jaimergp Sep 19, 2022
06cfade
Merge branch 'main' into menuinst-cep
jaimergp Nov 3, 2022
f501c97
define CONDA_ROOT_PREFIX so conda-standalone doesn't incorrectly use …
jaimergp Nov 23, 2022
0026dd6
Merge branch 'main' into menuinst-cep
jaimergp Nov 23, 2022
33fad98
set CONDA_ROOT_PREFIX on uninstaller too
jaimergp Dec 8, 2022
b5bf02b
add env shortcuts.txt to shar
jaimergp Dec 20, 2022
5febc0a
remove unused import
jaimergp Dec 20, 2022
f8449ed
Merge remote-tracking branch 'upstream/main' into menuinst-cep
jaimergp Jan 9, 2023
908c317
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Jan 10, 2023
a9987b2
ppd templating doesn't support nested ifs
jaimergp Jan 10, 2023
d767967
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Jan 17, 2023
f248db6
add 'enable_shortcuts' to shellcheck
jaimergp Jan 17, 2023
1272033
pre-commit
jaimergp Jan 17, 2023
d1b28e0
sync docs
jaimergp Jan 17, 2023
86508f6
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Jan 19, 2023
01d768a
fix shellcheck
jaimergp Jan 19, 2023
cbc8fb3
relax test
jaimergp Jan 19, 2023
e266c5c
only sh
jaimergp Jan 19, 2023
f76a60c
Merge remote-tracking branch 'upstream/main' into menuinst-cep
dbast Jan 26, 2023
1e23a0e
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Feb 8, 2023
dcfe76a
revert to 'all'
jaimergp Feb 10, 2023
3ab19c5
Merge branch 'main' into menuinst-cep
jaimergp Feb 15, 2023
1913d14
Merge branch 'main' into menuinst-cep
jaimergp Jun 19, 2023
d77d4a5
Merge branch 'main' into menuinst-cep
jaimergp Jun 22, 2023
3f0b97b
create .nonadmin if not run as sudo
jaimergp Jun 29, 2023
82a8143
add menuinst v2 tests
jaimergp Jul 6, 2023
2063525
Try with bundle_tools_2 and let's see what happens!
jaimergp Jul 7, 2023
5c62287
missing .exists()
jaimergp Jul 10, 2023
e95a193
fix expected paths
jaimergp Jul 10, 2023
a3ab442
print windows install logs to stderr
jaimergp Jul 10, 2023
5729bd3
move back to napari/label/bundle_tools_3
jaimergp Jul 10, 2023
5cec5c7
darwin in lowercase
jaimergp Jul 10, 2023
72baca8
debug windows ci
jaimergp Jul 10, 2023
5974931
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Jul 10, 2023
eeb8d09
try using cmd on windows?
jaimergp Jul 10, 2023
2997281
move tmate
jaimergp Jul 10, 2023
e834b96
assert before uninstalling
jaimergp Jul 10, 2023
61f2569
restore workflow
jaimergp Jul 10, 2023
3e5233c
force activate constructor-dev
jaimergp Jul 11, 2023
b16bb9e
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Jul 11, 2023
f4dee8a
do not initialize conda by default
jaimergp Jul 11, 2023
86dbb9d
restore main.yml
jaimergp Jul 11, 2023
4250889
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Jul 13, 2023
b0b2388
guard against undefined env vars
jaimergp Jul 13, 2023
6e054d9
Merge branch 'main' into menuinst-cep
jaimergp Aug 16, 2023
fa6c7f8
remove dup key
jaimergp Aug 21, 2023
09d3964
deprecate menuinst wrappers
jaimergp Aug 22, 2023
e57fe08
Merge branch 'main' into menuinst-cep
jaimergp Sep 7, 2023
2aa2458
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Dec 12, 2023
9f02022
Merge branch 'menuinst-cep' of github.com:jaimergp/constructor into m…
jaimergp Dec 12, 2023
8459f76
revert bad merge
jaimergp Dec 12, 2023
df8f97c
allow micromamba in some cases
jaimergp Dec 18, 2023
a58e839
better place for guards
jaimergp Dec 18, 2023
6260793
add docs
jaimergp Dec 18, 2023
5664a06
pre-commit
jaimergp Dec 18, 2023
30dca7c
rerender docs
jaimergp Dec 18, 2023
d43ec53
process all envs under $INSTDIR
jaimergp Dec 18, 2023
1ed708d
extend not append
jaimergp Dec 18, 2023
9daa6c7
this is already a list
jaimergp Dec 18, 2023
73671ae
enable micromamba tests on Windows
jaimergp Dec 18, 2023
eb2de34
do not skip here either
jaimergp Dec 18, 2023
6cede2b
do not test micromamba x windows yet
jaimergp Dec 18, 2023
b51d2e6
use regular conda-standalone nightly
jaimergp Dec 19, 2023
2dd8068
test miniforge shortcuts too
jaimergp Dec 19, 2023
9bae24a
pre-commit
jaimergp Dec 19, 2023
09e6b0d
debug
jaimergp Dec 19, 2023
ea8d0a3
retrigger
jaimergp Dec 19, 2023
5957eb3
revert
jaimergp Dec 19, 2023
ae80615
fix expected path
jaimergp Dec 19, 2023
3f6a4dd
debug conda-standalone 23.10
jaimergp Dec 19, 2023
9feb8c5
debug uninstall logs too
jaimergp Dec 19, 2023
48a1576
try more verbosity
jaimergp Dec 19, 2023
7c62ef6
fix SetDetailsPrint
jaimergp Dec 19, 2023
762a93c
logset on in uninstall
jaimergp Dec 19, 2023
d54149d
pass name
jaimergp Dec 19, 2023
06c53f6
tmate again
jaimergp Dec 20, 2023
56d9d73
revert debugging and require conda-standalone 23.11
jaimergp Dec 20, 2023
dd1321d
Merge branch 'main' of github.com:conda/constructor into menuinst-cep
jaimergp Dec 20, 2023
6aa66b7
comment version out for now
jaimergp Dec 20, 2023
f4bb479
remove libmamba specific test
jaimergp Dec 20, 2023
0af4bb4
add news
jaimergp Dec 20, 2023
a73a27a
skip / xfail as needed
jaimergp Dec 20, 2023
137b5e6
warn early about incompatible conda-exes
jaimergp Dec 20, 2023
93d43dc
test menu_packages from extra_envs
jaimergp Dec 20, 2023
54af393
debug
jaimergp Dec 20, 2023
ceadb38
fix directory
jaimergp Dec 20, 2023
5657c99
revert debugging
jaimergp Dec 20, 2023
ae51ac0
allow None
jaimergp Dec 20, 2023
af74ec4
pre-commit
jaimergp Dec 20, 2023
7cd489b
win-select menu_packages too
jaimergp Dec 20, 2023
6ea01e1
revert -k selector
jaimergp Dec 20, 2023
858371a
mark as incompatible, not disabled
jaimergp Dec 20, 2023
e585dea
fix shellcheck tests
jaimergp Dec 20, 2023
d2a1dc6
fix conda_exe param
jaimergp Dec 20, 2023
ce635fa
fix $env_shortcuts
jaimergp Dec 20, 2023
3627370
rename conda.exe to _conda on Unix
jaimergp Jan 4, 2024
16ee77a
pre-commit
jaimergp Jan 4, 2024
69cddad
pre-commit
jaimergp Jan 4, 2024
03cd520
compare enable_shortcuts to strings
jaimergp Jan 5, 2024
c5ee5f1
return early
jaimergp Jan 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ _required:_ no<br/>
_type:_ list<br/>

A list of packages with menu items to be installed. The packages must have
necessary metadata in `Menu/<package name>.json`). Menu items are currently
only supported on Windows. By default, all menu items will be installed;
supplying this list allows a subset to be selected instead.
necessary metadata in `Menu/<package name>.json`). By default, all menu items
found in the installation will be created; supplying this list allows a
subset to be selected instead. If an empty list is supplied, no shortcuts will
be created.

If all environments (`extra_envs` included) set `menu_packages` to an empty list,
no UI options about shortcuts will be offered to the user.

### `ignore_duplicate_files`

Expand Down Expand Up @@ -217,6 +221,8 @@ name) to a dictionary of options:
an empty list.
- `user_requested_specs` (list of str): same as the global option, but for this env;
if not provided, global value is _not_ used
- `menu_packages` (list of str): same as the global option, for this env;
if not provided, the global value is _not_ used.

Notes:
- `ignore_duplicate_files` will always be considered `True` if `extra_envs` is in use.
Expand Down
14 changes: 10 additions & 4 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@
is contained as a result of resolving the specs for `python 2.7`.
'''),

('menu_packages', False, list, '''
('menu_packages', False, list, '''
A list of packages with menu items to be installed. The packages must have
necessary metadata in `Menu/<package name>.json`). Menu items are currently
only supported on Windows. By default, all menu items will be installed;
supplying this list allows a subset to be selected instead.
necessary metadata in `Menu/<package name>.json`). By default, all menu items
found in the installation will be created; supplying this list allows a
subset to be selected instead. If an empty list is supplied, no shortcuts will
be created.
marcoesters marked this conversation as resolved.
Show resolved Hide resolved

If all environments (`extra_envs` included) set `menu_packages` to an empty list,
no UI options about shortcuts will be offered to the user.
'''),

('ignore_duplicate_files', False, bool, '''
Expand Down Expand Up @@ -148,6 +152,8 @@
an empty list.
- `user_requested_specs` (list of str): same as the global option, but for this env;
if not provided, global value is _not_ used
- `menu_packages` (list of str): same as the global option, for this env;
if not provided, the global value is _not_ used.

Notes:
- `ignore_duplicate_files` will always be considered `True` if `extra_envs` is in use.
Expand Down
54 changes: 47 additions & 7 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ KEEP_PKGS=1
KEEP_PKGS=0
#endif
SKIP_SCRIPTS=0
#if enable_shortcuts
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
SKIP_SHORTCUTS=0
#endif
TEST=0
REINSTALL=0
USAGE="
Expand All @@ -66,6 +69,9 @@ Installs __NAME__ __VERSION__
-p PREFIX install prefix, defaults to $PREFIX
#endif
-s skip running pre/post-link/install scripts
#if enable_shortcuts
-m disable the creation of menu items / shortcuts
#endif
-u update an existing installation
#if has_conda
-t run package tests after installation (may install conda-build)
Expand All @@ -76,7 +82,11 @@ Installs __NAME__ __VERSION__
# However getopt is not standardized and the version on Mac has different
# behaviour. getopts is good enough for what we need :)
# More info: https://unix.stackexchange.com/questions/62950/
#if enable_shortcuts
while getopts "bifhkp:smut" x; do
#else
while getopts "bifhkp:sut" x; do
#endif
case "$x" in
h)
printf "%s\\n" "$USAGE"
Expand All @@ -100,6 +110,11 @@ while getopts "bifhkp:sut" x; do
s)
SKIP_SCRIPTS=1
;;
#if enable_shortcuts
m)
SKIP_SHORTCUTS=1
;;
#endif
u)
FORCE=1
;;
Expand Down Expand Up @@ -386,7 +401,7 @@ cd "$PREFIX"
unset PYTHON_SYSCONFIGDATA_NAME _CONDA_PYTHON_SYSCONFIGDATA_NAME

# the first binary payload: the standalone conda executable
CONDA_EXEC="$PREFIX/conda.exe"
CONDA_EXEC="$PREFIX/_conda.exe"
extract_range "${boundary0}" "${boundary1}" > "$CONDA_EXEC"
chmod +x "$CONDA_EXEC"

Expand Down Expand Up @@ -438,13 +453,26 @@ mkdir -p ~/.conda > /dev/null 2>&1

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

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

# shellcheck disable=SC2086
CONDA_ROOT_PREFIX="$PREFIX" \
CONDA_SAFETY_CHECKS=disabled \
CONDA_EXTRA_SAFETY_CHECKS=no \
CONDA_CHANNELS="__CHANNELS__" \
CONDA_PKGS_DIRS="$PREFIX/pkgs" \
"$CONDA_EXEC" install --offline --file "$PREFIX/pkgs/env.txt" -yp "$PREFIX" || exit 1
"$CONDA_EXEC" install --offline --file "$PREFIX/pkgs/env.txt" -yp "$PREFIX" $shortcuts || exit 1
rm -f "$PREFIX/pkgs/env.txt"

#The templating doesn't support nested if statements
#if has_conda
mkdir -p "$PREFIX/envs"
for env_pkgs in "${PREFIX}"/pkgs/envs/*/; do
Expand All @@ -461,13 +489,27 @@ for env_pkgs in "${PREFIX}"/pkgs/envs/*/; do
else
env_channels="__CHANNELS__"
fi

#endif
#if has_conda and enable_shortcuts
if [ "$SKIP_SHORTCUTS" = "1" ]; then
env_shortcuts="--no-shortcuts"
else
# This file is guaranteed to exist, even if empty
env_shortcuts=$(cat "${env_pkgs}shortcuts.txt")
rm -f "${env_pkgs}shortcuts.txt"
fi
#else
env_shortcuts="--no-shortcuts"
#endif
#if has_conda
# TODO: custom shortcuts per env?
# shellcheck disable=SC2086
CONDA_ROOT_PREFIX="$PREFIX" \
CONDA_SAFETY_CHECKS=disabled \
CONDA_EXTRA_SAFETY_CHECKS=no \
CONDA_CHANNELS="$env_channels" \
CONDA_PKGS_DIRS="$PREFIX/pkgs" \
"$CONDA_EXEC" install --offline --file "${env_pkgs}env.txt" -yp "$PREFIX/envs/$env_name" || exit 1
"$CONDA_EXEC" install --offline --file "${env_pkgs}env.txt" -yp "$PREFIX/envs/$env_name" $env_shortcuts || exit 1
rm -f "${env_pkgs}env.txt"
done
#endif
Expand All @@ -477,9 +519,6 @@ __INSTALL_COMMANDS__
POSTCONDA="$PREFIX/postconda.tar.bz2"
"$CONDA_EXEC" constructor --prefix "$PREFIX" --extract-tarball < "$POSTCONDA" || exit 1
rm -f "$POSTCONDA"

rm -f "$CONDA_EXEC"

rm -rf "$PREFIX/install_tmp"
export TMP="$TMP_BACKUP"

Expand Down Expand Up @@ -620,4 +659,5 @@ fi
#endif

exit 0
# shellcheck disable=SC2317
@@END_HEADER@@
10 changes: 10 additions & 0 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
if config_key == "environment_file":
env_config[config_key] = abspath(join(dir_path, value))

# 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()
)
)

info['installer_type'] = itypes[0]
fcp_main(info, verbose=verbose, dry_run=dry_run, conda_exe=conda_exe)
if dry_run:
Expand Down
19 changes: 13 additions & 6 deletions constructor/nsis/OptionsDialog.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ Function mui_AnaCustomOptions_InitDefaults
StrCpy $Ana_RegisterSystemPython_State ${BST_CHECKED}
${EndIf}
${If} $Ana_CreateShortcuts_State == ""
StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED}
${If} "${ENABLE_SHORTCUTS}" == "yes"
StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED}
${Else}
StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED}
${EndIf}
${EndIf}
${EndIf}
FunctionEnd
Expand All @@ -70,12 +74,15 @@ Function mui_AnaCustomOptions_Show

# We will use $5 as the y axis accumulator, starting at 0
# We sum the the number of 'u' units added by 'NSD_Create*' functions
IntOp $5 0 + 0

${NSD_CreateCheckbox} 0 0u 100% 11u "Create start menu shortcuts (supported packages only)."
IntOp $5 0 + 11
Pop $mui_AnaCustomOptions.CreateShortcuts
${NSD_SetState} $mui_AnaCustomOptions.CreateShortcuts $Ana_CreateShortcuts_State
${NSD_OnClick} $mui_AnaCustomOptions.CreateShortcuts CreateShortcuts_OnClick
${If} "${ENABLE_SHORTCUTS}" == "yes"
${NSD_CreateCheckbox} 0 0u 100% 11u "Create start menu shortcuts (supported packages only)."
IntOp $5 $5 + 11
Pop $mui_AnaCustomOptions.CreateShortcuts
${NSD_SetState} $mui_AnaCustomOptions.CreateShortcuts $Ana_CreateShortcuts_State
${NSD_OnClick} $mui_AnaCustomOptions.CreateShortcuts CreateShortcuts_OnClick
${EndIf}

${If} "${SHOW_ADD_TO_PATH}" == "yes"
# AddToPath is only an option for JustMe installations; it is disabled for AllUsers
Expand Down
32 changes: 15 additions & 17 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Unicode "true"
!define DEFAULT_PREFIX_ALL_USERS __DEFAULT_PREFIX_ALL_USERS__
!define PRE_INSTALL_DESC __PRE_INSTALL_DESC__
!define POST_INSTALL_DESC __POST_INSTALL_DESC__
!define MENU_PKGS "@MENU_PKGS@"
!define ENABLE_SHORTCUTS __ENABLE_SHORTCUTS__
!define SHOW_REGISTER_PYTHON __SHOW_REGISTER_PYTHON__
!define SHOW_ADD_TO_PATH __SHOW_ADD_TO_PATH__
!define PRODUCT_NAME "${NAME} ${VERSION} (${ARCH})"
Expand Down Expand Up @@ -288,14 +288,18 @@ FunctionEnd
${EndIf}
${EndIf}

ClearErrors
${GetOptions} $ARGV "/NoShortcuts=" $ARGV_NoShortcuts
${IfNot} ${Errors}
${If} $ARGV_NoShortcuts = "1"
StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED}
${ElseIf} $ARGV_NoShortcuts = "0"
StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED}
${If} "${ENABLE_SHORTCUTS}" == "yes"
ClearErrors
${GetOptions} $ARGV "/NoShortcuts=" $ARGV_NoShortcuts
${IfNot} ${Errors}
${If} $ARGV_NoShortcuts = "1"
StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED}
${ElseIf} $ARGV_NoShortcuts = "0"
StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED}
${EndIf}
${EndIf}
${Else}
StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED}
${EndIf}

ClearErrors
Expand Down Expand Up @@ -1010,6 +1014,7 @@ Section "Install"

System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_SAFETY_CHECKS", "disabled").r0'
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_EXTRA_SAFETY_CHECKS", "no").r0'
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0'
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_PKGS_DIRS", "$INSTDIR\pkgs")".r0'
# Extra info for pre and post install scripts
# NOTE: If more vars are added, make sure to update the examples/scripts tests too
Expand Down Expand Up @@ -1050,14 +1055,6 @@ Section "Install"

AddSize @SIZE@

${If} $Ana_CreateShortcuts_State = ${BST_CHECKED}
DetailPrint "Creating @NAME@ menus..."
push '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --make-menus @MENU_PKGS@'
push 'Failed to create menus'
push 'WithLog'
call AbortRetryNSExecWait
${EndIf}

#if has_conda is True
DetailPrint "Initializing conda directories..."
push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs'
Expand Down Expand Up @@ -1159,8 +1156,9 @@ SectionEnd
!macroend

Section "Uninstall"
# Remove menu items, path entries
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0'

# Remove menu items, path entries
DetailPrint "Deleting @NAME@ menus..."
nsExec::ExecToLog '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --rm-menus'

Expand Down
16 changes: 16 additions & 0 deletions constructor/osx/check_shortcuts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -eux

# $2 is the install location, which is ~ by default
# but which the user can change.
PREFIX="$2/__NAME_LOWER__"
PREFIX=$(cd "$PREFIX"; pwd)

# If the UI selected the "Create shortcuts" option
# we create a sentinel file that will be checked for existence
# 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
touch "$PREFIX/pkgs/user_wants_shortcuts"
28 changes: 23 additions & 5 deletions constructor/osx/run_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ echo "PREFIX=$PREFIX"
CONDA_EXEC="$PREFIX/conda.exe"
# /COMMON UTILS

# Check whether the user wants shortcuts or not
# See check_shortcuts.sh script for details
if [[ -f "$PREFIX/pkgs/user_wants_shortcuts" ]]; then
shortcuts="__SHORTCUTS__"
else
shortcuts="--no-shortcuts"
fi

# Perform the conda install
notify "Installing packages. This might take a few minutes."
if ! CONDA_SAFETY_CHECKS=disabled \
# shellcheck disable=SC2086
if ! \
CONDA_ROOT_PREFIX="$PREFIX" \
CONDA_SAFETY_CHECKS=disabled \
CONDA_EXTRA_SAFETY_CHECKS=no \
CONDA_CHANNELS=__CHANNELS__ \
CONDA_PKGS_DIRS="$PREFIX/pkgs" \
"$CONDA_EXEC" install --offline --file "$PREFIX/pkgs/env.txt" -yp "$PREFIX"; then
"$CONDA_EXEC" install --offline --file "$PREFIX/pkgs/env.txt" -yp "$PREFIX" $shortcuts; then
echo "ERROR: could not complete the conda install"
exit 1
fi
Expand Down Expand Up @@ -60,20 +71,27 @@ for env_pkgs in "${PREFIX}"/pkgs/envs/*/; do
else
env_channels="__CHANNELS__"
fi
# TODO: custom channels per env?
if [[ -f "$PREFIX/pkgs/user_wants_shortcuts" ]]; then
# This file is guaranteed to exist, even if empty
env_shortcuts=$(cat "${env_pkgs}shortcuts.txt")
rm -f "${env_pkgs}shortcuts.txt"
else
env_shortcuts="--no-shortcuts"
fi
# TODO: custom shortcuts per env?
# shellcheck disable=SC2086
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm... disbaling SC2086 prevents detection of missing quotes for the entire command...

does the command rely on splitting the $env_shortcuts parameter on spaces... there are examples in https://www.shellcheck.net/wiki/SC2086 on how to do that without entirely disabling SC2086.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it has to split. I tried the array method but that's not POSIX, and then I gave up. 😂

CONDA_ROOT_PREFIX="$PREFIX" \
CONDA_SAFETY_CHECKS=disabled \
CONDA_EXTRA_SAFETY_CHECKS=no \
CONDA_CHANNELS="$env_channels" \
CONDA_PKGS_DIRS="$PREFIX/pkgs" \
"$CONDA_EXEC" install --offline --file "${env_pkgs}env.txt" -yp "$PREFIX/envs/$env_name" || exit 1
"$CONDA_EXEC" install --offline --file "${env_pkgs}env.txt" -yp "$PREFIX/envs/$env_name" $env_shortcuts || exit 1
# Move the prepackaged history file into place
mv "${env_pkgs}/conda-meta/history" "$PREFIX/envs/$env_name/conda-meta/history"
rm -f "${env_pkgs}env.txt"
done

# Cleanup!
rm -f "$CONDA_EXEC"
find "$PREFIX/pkgs" -type d -empty -exec rmdir {} \; 2>/dev/null || :

__WRITE_CONDARC__
Expand Down
Loading