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 all 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
10 changes: 1 addition & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ jobs:
conda-standalone: conda-standalone
- os: windows
python-version: "3.11"
# conda-standalone: micromamba
conda-standalone: conda-standalone-nightly
# Micromamba doesn't support Windows yet (menuinst features missing)
# - os: windows
# python-version: 3.11
# conda-standalone: micromamba

env:
PYTHONUNBUFFERED: "1"
Expand Down Expand Up @@ -133,7 +130,6 @@ jobs:
- name: Run examples
env:
CONSTRUCTOR_EXAMPLES_KEEP_ARTIFACTS: "${{ runner.temp }}/examples_artifacts"
# signtool only exists on Windows, but doesn't cause errors on unix when absent
CONSTRUCTOR_SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe"
run: |
rm -rf coverage.json
Expand All @@ -144,10 +140,6 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: integration
- name: Test with conda-libmamba-solver
run: |
conda install -yq conda-libmamba-solver
CONDA_SOLVER=libmamba CONDA_VERBOSITY=1 pytest -vv tests/test_examples.py -k noconda
- name: Check docs are up-to-date
if: matrix.check-docs
run: |
Expand Down
17 changes: 12 additions & 5 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,16 @@ _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.

Note: This option is not fully implemented when `micromamba` is used as
the `--conda-exe` binary. The only accepted value is an empty list (`[]`).

### `ignore_duplicate_files`

Expand Down Expand Up @@ -220,12 +227,12 @@ 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.
- `conda` needs to be present in the `base` environment (via `specs`)
- support for `menu_packages` is planned, but not possible right now. For now, all packages
in an `extra_envs` config will be allowed to create their shortcuts.
- If a global `exclude` option is used, it will have an effect on the environments created
by `extra_envs` too. For example, if the global environment excludes `tk`, none of the
extra environments will have it either. Unlike the global option, an error will not be
Expand Down
25 changes: 15 additions & 10 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@
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.

Note: This option is not fully implemented when `micromamba` is used as
the `--conda-exe` binary. The only accepted value is an empty list (`[]`).
'''),

('ignore_duplicate_files', False, bool, '''
Expand Down Expand Up @@ -152,12 +159,12 @@
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.
- `conda` needs to be present in the `base` environment (via `specs`)
- support for `menu_packages` is planned, but not possible right now. For now, all packages
in an `extra_envs` config will be allowed to create their shortcuts.
- If a global `exclude` option is used, it will have an effect on the environments created
by `extra_envs` too. For example, if the global environment excludes `tk`, none of the
extra environments will have it either. Unlike the global option, an error will not be
Expand Down Expand Up @@ -599,9 +606,7 @@
"channels_remap": (list, tuple),
"user_requested_specs": (list, tuple),
"exclude": (list, tuple),
# TODO: we can't support menu_packages for extra envs yet
# will implement when the PR for new menuinst lands
# "menu_packages": (list, tuple),
"menu_packages": (list, tuple),
}

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -766,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: 6 additions & 4 deletions constructor/fcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def getsize(filename):


def warn_menu_packages_missing(precs, menu_packages):
if not menu_packages:
return
all_names = {prec.name for prec in precs}
for name in menu_packages:
if name not in all_names:
Expand Down Expand Up @@ -236,7 +238,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 +378,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 +410,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 +464,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
68 changes: 60 additions & 8 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ KEEP_PKGS=1
KEEP_PKGS=0
#endif
SKIP_SCRIPTS=0
#if enable_shortcuts == "true"
SKIP_SHORTCUTS=0
#endif
TEST=0
REINSTALL=0
USAGE="
Expand All @@ -70,6 +73,9 @@ Installs ${INSTALLER_NAME} ${INSTALLER_VER}
-p PREFIX install prefix, defaults to $PREFIX
#endif
-s skip running pre/post-link/install scripts
#if enable_shortcuts == 'true'
-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 @@ -80,7 +86,11 @@ Installs ${INSTALLER_NAME} ${INSTALLER_VER}
# 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 == "true"
while getopts "bifhkp:smut" x; do
#else
while getopts "bifhkp:sut" x; do
#endif
case "$x" in
h)
printf "%s\\n" "$USAGE"
Expand All @@ -104,6 +114,11 @@ while getopts "bifhkp:sut" x; do
s)
SKIP_SCRIPTS=1
;;
#if enable_shortcuts == "true"
m)
SKIP_SHORTCUTS=1
;;
#endif
u)
FORCE=1
;;
Expand Down Expand Up @@ -391,14 +406,19 @@ 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"
extract_range "${boundary0}" "${boundary1}" > "$CONDA_EXEC"
chmod +x "$CONDA_EXEC"

export TMP_BACKUP="${TMP:-}"
export TMP="$PREFIX/install_tmp"
mkdir -p "$TMP"

# Create $PREFIX/.nonadmin if the installation didn't require superuser permissions
if [ "$(id -u)" -ne 0 ]; then
touch "$PREFIX/.nonadmin"
fi
marcoesters marked this conversation as resolved.
Show resolved Hide resolved

# the second binary payload: the tarball of packages
printf "Unpacking payload ...\n"
extract_range $boundary1 $boundary2 | \
Expand Down Expand Up @@ -445,14 +465,31 @@ test -d ~/.conda || mkdir -p ~/.conda >/dev/null 2>/dev/null || test -d ~/.conda

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

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

# shellcheck disable=SC2086
CONDA_ROOT_PREFIX="$PREFIX" \
CONDA_REGISTER_ENVS="__REGISTER_ENVS__" \
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 @@ -469,14 +506,31 @@ for env_pkgs in "${PREFIX}"/pkgs/envs/*/; do
else
env_channels="__CHANNELS__"
fi

# TODO: custom shortcuts per env?
#endif
#if has_conda and enable_shortcuts == "true"
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
#endif
#if has_conda and enable_shortcuts == "false"
env_shortcuts="--no-shortcuts"
#endif
#if has_conda and enable_shortcuts == "incompatible"
env_shortcuts=""
#endif
#if has_conda
# shellcheck disable=SC2086
CONDA_ROOT_PREFIX="$PREFIX" \
CONDA_REGISTER_ENVS="__REGISTER_ENVS__" \
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 @@ -486,9 +540,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 @@ -630,4 +681,5 @@ fi
#endif

exit 0
# shellcheck disable=SC2317
@@END_HEADER@@
25 changes: 22 additions & 3 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

from . import __version__
from .build_outputs import process_build_outputs
from .conda_interface import SUPPORTED_PLATFORMS, cc_platform
from .conda_interface import SUPPORTED_PLATFORMS
from .conda_interface import VersionOrder as Version
from .conda_interface import cc_platform
from .construct import generate_key_info_list, ns_platform
from .construct import parse as construct_parse
from .construct import verify as construct_verify
from .fcp import main as fcp_main
from .utils import normalize_path, yield_lines
from .utils import identify_conda_exe, normalize_path, yield_lines

DEFAULT_CACHE_DIR = os.getenv('CONSTRUCTOR_CACHE', '~/.conda/constructor')

Expand Down Expand Up @@ -90,7 +92,7 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
if platform != cc_platform and 'pkg' in itypes and not cc_platform.startswith('osx-'):
sys.exit("Error: cannot construct a macOS 'pkg' installer on '%s'" % cc_platform)
if osname == "win" and "micromamba" in os.path.basename(info['_conda_exe']):
# TODO: Remove when shortcut creation is implemented on micromamba
# TODO: Investigate errors on Windows and re-enable
sys.exit("Error: micromamba is not supported on Windows installers.")

logger.debug('conda packages download: %s', info['_download_dir'])
Expand Down Expand Up @@ -145,6 +147,23 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
if config_key == "environment_file":
env_config[config_key] = abspath(join(dir_path, value))

exe_name, exe_version = identify_conda_exe(info.get("_conda_exe"))
if sys.platform != "win32" and (
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'] = "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()
)
)

info['installer_type'] = itypes[0]
fcp_main(info, verbose=verbose, dry_run=dry_run, conda_exe=conda_exe)
if dry_run:
Expand Down
Loading