From f0db8730cb06084eea3c0d35a7085dfd38cf3517 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Mon, 16 Dec 2024 16:21:01 +0100 Subject: [PATCH 1/5] fix: Adapt shell init for mamba 2 Signed-off-by: Julien Jerphanion --- constructor/header.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/constructor/header.sh b/constructor/header.sh index 0930a58f3..6b4df2d44 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -671,11 +671,22 @@ if [ "$BATCH" = "0" ]; then *) "$PREFIX/bin/python" -m conda init ;; esac if [ -f "$PREFIX/bin/mamba" ]; 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 + # 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 %} From d57dd6fc65529138343f252120f067b09c6567e6 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 17 Dec 2024 11:04:07 +0100 Subject: [PATCH 2/5] docs: Add changelog entry Signed-off-by: Julien Jerphanion --- news/914-shell-init-on-mamba-2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/914-shell-init-on-mamba-2 diff --git a/news/914-shell-init-on-mamba-2 b/news/914-shell-init-on-mamba-2 new file mode 100644 index 000000000..a9e3468c1 --- /dev/null +++ b/news/914-shell-init-on-mamba-2 @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Add support of mamba 2 + +### Deprecations + +* + +### Docs + +* + +### Other + +* From f50af221bf6de4722c5272a827167c4a826c1936 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Thu, 19 Dec 2024 16:38:44 +0100 Subject: [PATCH 3/5] Reference PR number in the changelog Co-authored-by: jaimergp --- news/914-shell-init-on-mamba-2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/914-shell-init-on-mamba-2 b/news/914-shell-init-on-mamba-2 index a9e3468c1..680d52dcc 100644 --- a/news/914-shell-init-on-mamba-2 +++ b/news/914-shell-init-on-mamba-2 @@ -4,7 +4,7 @@ ### Bug fixes -* Add support of mamba 2 +* Add support of mamba v2 shell initialization. (#914) ### Deprecations From 5976c3527341e2fe995470b67df9fce619da70be Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Fri, 10 Jan 2025 16:39:46 +0100 Subject: [PATCH 4/5] Update Miniforge example Signed-off-by: Julien Jerphanion --- examples/miniforge/construct.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index f85c4022d..8026f5c46 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -1,5 +1,5 @@ name: Miniforge3 -version: 24.11.2-1 +version: 25.0.0 company: conda-forge license_file: EULA.txt @@ -13,7 +13,7 @@ transmute_file_type: .conda specs: - python 3.12.* - conda 24.11.2 - - mamba 1.5.12 + - mamba 2 - pip - miniforge_console_shortcut 1.* # [win] From b4de46060e32a90d55ee266ac54f06e1db289961 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Fri, 10 Jan 2025 17:59:38 +0100 Subject: [PATCH 5/5] test: Add test for mamba 2.0.5 Signed-off-by: Julien Jerphanion Co-authored-by: jaimergp --- examples/miniforge/construct.yaml | 2 +- examples/miniforge/test_install.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index 8026f5c46..cdb58f045 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -13,7 +13,7 @@ transmute_file_type: .conda specs: - python 3.12.* - conda 24.11.2 - - mamba 2 + - mamba 2.0.5 - pip - miniforge_console_shortcut 1.* # [win] diff --git a/examples/miniforge/test_install.sh b/examples/miniforge/test_install.sh index 27847c14e..d5311c473 100644 --- a/examples/miniforge/test_install.sh +++ b/examples/miniforge/test_install.sh @@ -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"