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

fix: Adapt shell init for mamba 2 #914

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 16 additions & 5 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,22 @@ if [ "$BATCH" = "0" ]; then
*) "$PREFIX/bin/python" -m conda init ;;
esac
if [ -f "$PREFIX/bin/mamba" ]; then
jjerphan marked this conversation as resolved.
Show resolved Hide resolved
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m mamba.mamba init zsh ;;
*) "$PREFIX/bin/python" -m mamba.mamba init ;;
esac
# If the version of mamba is <2.0.0, we preferably use the `mamba` python module
# to perform the initialization.
#
# Otherwise (i.e. as of 2.0.0), we use the `mamba shell init` command
if [ "$("$PREFIX/bin/mamba" --version | cut -d' ' -f2 | cut -d'.' -f1)" -lt 2 ]; then
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m mamba.mamba init zsh ;;
*) "$PREFIX/bin/python" -m mamba.mamba init ;;
esac
else
case $SHELL in
*zsh) "$PREFIX/bin/mamba" shell init --shell zsh ;;
*) "$PREFIX/bin/mamba" shell init ;;
esac
fi
fi
fi
{%- endif %}
Expand Down
4 changes: 2 additions & 2 deletions examples/miniforge/construct.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Miniforge3
version: 24.11.2-1
version: 25.0.0
company: conda-forge
license_file: EULA.txt

Expand All @@ -13,7 +13,7 @@ transmute_file_type: .conda
specs:
- python 3.12.*
- conda 24.11.2
- mamba 1.5.12
- mamba 2.0.5
- pip
- miniforge_console_shortcut 1.* # [win]

Expand Down
27 changes: 26 additions & 1 deletion examples/miniforge/test_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ conda info -v
echo "+ conda config"
conda config --show-sources

echo "+ Testing channels"
echo "+ Testing conda channels"
conda config --show --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert 'conda-forge' in info['channels'], info"
echo " OK"

echo "+ Testing mamba installation"
mamba --version
echo " OK"

echo "+ mamba info"
mamba info

echo "+ mamba config sources"
mamba config sources

echo "+ mamba config list"
mamba config list

echo "+ Testing mamba 2 version"
mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba version'] == '2.0.5', info"
echo " OK"

echo "+ Testing libmambapy 2 version"
python -c "import libmambapy; assert libmambapy.__version__ == '2.0.5', f'libmamba version got: {libmambapy.__version__}; expected: 2.0.5'"
echo " OK"

echo "+ Testing mamba channels"
mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert any('conda-forge' in c for c in info['channels']), info"
echo " OK"
19 changes: 19 additions & 0 deletions news/914-shell-init-on-mamba-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Add support of mamba v2 shell initialization. (#914)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
Loading