From aad1a018473e1e8c326f2dccfef8910d82f76744 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Mon, 27 Jan 2025 19:07:52 +0100 Subject: [PATCH 01/13] fix: Version parsing for mamba 1 Signed-off-by: Julien Jerphanion --- constructor/header.sh | 2 +- .../{miniforge => miniforge-mamba1}/EULA.txt | 0 examples/miniforge-mamba1/construct.yaml | 25 ++++++++++++ .../test_install.bat | 0 examples/miniforge-mamba1/test_install.sh | 38 +++++++++++++++++++ examples/miniforge-mamba2/EULA.txt | 28 ++++++++++++++ .../construct.yaml | 0 examples/miniforge-mamba2/test_install.bat | 8 ++++ .../test_install.sh | 0 9 files changed, 100 insertions(+), 1 deletion(-) rename examples/{miniforge => miniforge-mamba1}/EULA.txt (100%) create mode 100644 examples/miniforge-mamba1/construct.yaml rename examples/{miniforge => miniforge-mamba1}/test_install.bat (100%) create mode 100644 examples/miniforge-mamba1/test_install.sh create mode 100644 examples/miniforge-mamba2/EULA.txt rename examples/{miniforge => miniforge-mamba2}/construct.yaml (100%) create mode 100644 examples/miniforge-mamba2/test_install.bat rename examples/{miniforge => miniforge-mamba2}/test_install.sh (100%) diff --git a/constructor/header.sh b/constructor/header.sh index 6c6bc4edb..3424c74e9 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -680,7 +680,7 @@ if [ "$BATCH" = "0" ]; then # 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 + if [ "$("$PREFIX/bin/mamba" --version | head -n 1 | 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 ;; diff --git a/examples/miniforge/EULA.txt b/examples/miniforge-mamba1/EULA.txt similarity index 100% rename from examples/miniforge/EULA.txt rename to examples/miniforge-mamba1/EULA.txt diff --git a/examples/miniforge-mamba1/construct.yaml b/examples/miniforge-mamba1/construct.yaml new file mode 100644 index 000000000..f85c4022d --- /dev/null +++ b/examples/miniforge-mamba1/construct.yaml @@ -0,0 +1,25 @@ +name: Miniforge3 +version: 24.11.2-1 +company: conda-forge +license_file: EULA.txt + +channels: + - conda-forge + +write_condarc: True +keep_pkgs: True +transmute_file_type: .conda + +specs: + - python 3.12.* + - conda 24.11.2 + - mamba 1.5.12 + - pip + - miniforge_console_shortcut 1.* # [win] + +# Added for extra testing +installer_type: all +post_install: test_install.sh # [unix] +post_install: test_install.bat # [win] +initialize_by_default: false +register_python: False diff --git a/examples/miniforge/test_install.bat b/examples/miniforge-mamba1/test_install.bat similarity index 100% rename from examples/miniforge/test_install.bat rename to examples/miniforge-mamba1/test_install.bat diff --git a/examples/miniforge-mamba1/test_install.sh b/examples/miniforge-mamba1/test_install.sh new file mode 100644 index 000000000..d93147b51 --- /dev/null +++ b/examples/miniforge-mamba1/test_install.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -eo pipefail +echo "Added by test-install script" > "$PREFIX/test_install_sentinel.txt" + +echo "sourcing..." +# shellcheck disable=SC1091 +source "$PREFIX/etc/profile.d/conda.sh" + +conda activate "$PREFIX" + +echo "+ conda info" +conda info -v + +echo "+ conda config" +conda config --show-sources + +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 "+ Testing mamba version" +mamba --version | grep mamba | cut -d' ' -f2 | grep -q 1.5.12 +mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2 + +mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '1.5.12', info" +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" diff --git a/examples/miniforge-mamba2/EULA.txt b/examples/miniforge-mamba2/EULA.txt new file mode 100644 index 000000000..d3bdc5b4e --- /dev/null +++ b/examples/miniforge-mamba2/EULA.txt @@ -0,0 +1,28 @@ +Copyright (c) 2016, Example, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Example, Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL EXAMPLE, INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The License has to be read correctly so that dollar signs don't lead to an unset +parameter error: +You have to pay US $8, if you can read this. diff --git a/examples/miniforge/construct.yaml b/examples/miniforge-mamba2/construct.yaml similarity index 100% rename from examples/miniforge/construct.yaml rename to examples/miniforge-mamba2/construct.yaml diff --git a/examples/miniforge-mamba2/test_install.bat b/examples/miniforge-mamba2/test_install.bat new file mode 100644 index 000000000..6f1229862 --- /dev/null +++ b/examples/miniforge-mamba2/test_install.bat @@ -0,0 +1,8 @@ +echo Added by test-install script > "%PREFIX%\test_install_sentinel.txt" +SetLocal EnableDelayedExpansion + +@ECHO ON +call "%PREFIX%\Scripts\activate.bat +conda info || exit 1 +conda config --show-sources || exit 1 +conda config --show --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert 'conda-forge' in info['channels'], info" diff --git a/examples/miniforge/test_install.sh b/examples/miniforge-mamba2/test_install.sh similarity index 100% rename from examples/miniforge/test_install.sh rename to examples/miniforge-mamba2/test_install.sh From b594f8532f61bab42cf3e9aa5f6b9e3c33d0d49c Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Mon, 27 Jan 2025 19:24:14 +0100 Subject: [PATCH 02/13] Add news entry Signed-off-by: Julien Jerphanion --- news/936-version-parsing-mamba-1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/936-version-parsing-mamba-1 diff --git a/news/936-version-parsing-mamba-1 b/news/936-version-parsing-mamba-1 new file mode 100644 index 000000000..de770a5c5 --- /dev/null +++ b/news/936-version-parsing-mamba-1 @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Fix version parsing when mamba 1 is used (#936) + +### Deprecations + +* + +### Docs + +* + +### Other + +* From 04531bff6615a08b30cd6b2f4e0b36d57d8dac2d Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 28 Jan 2025 09:23:27 +0100 Subject: [PATCH 03/13] Test miniforge-mamba1 and miniforge-mamba2 examples Signed-off-by: Julien Jerphanion --- tests/test_examples.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 11b7def98..8ebd6ac33 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -419,8 +419,9 @@ def test_example_extra_files(tmp_path, request): ), reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.", ) -def test_example_miniforge(tmp_path, request): - input_path = _example_path("miniforge") +@pytest.mark.parametrize("miniforge_example", ("miniforge-mamba1", "miniforge-mamba2")) +def test_example_miniforge(tmp_path, request, miniforge_example): + input_path = _example_path(miniforge_example) for installer, install_dir in create_installer(input_path, tmp_path): if installer.suffix == ".sh": # try both batch and interactive installations From d0d8b9f88beca75d77839428f16e08b5117f0faa Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 28 Jan 2025 11:25:15 +0100 Subject: [PATCH 04/13] Revert "Test miniforge-mamba1 and miniforge-mamba2 examples" This reverts commit 04531bff6615a08b30cd6b2f4e0b36d57d8dac2d. --- tests/test_examples.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 8ebd6ac33..11b7def98 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -419,9 +419,8 @@ def test_example_extra_files(tmp_path, request): ), reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.", ) -@pytest.mark.parametrize("miniforge_example", ("miniforge-mamba1", "miniforge-mamba2")) -def test_example_miniforge(tmp_path, request, miniforge_example): - input_path = _example_path(miniforge_example) +def test_example_miniforge(tmp_path, request): + input_path = _example_path("miniforge") for installer, install_dir in create_installer(input_path, tmp_path): if installer.suffix == ".sh": # try both batch and interactive installations From c601b150fd0e57b0c52d0dfe25ee4d12c7cf111a Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 28 Jan 2025 11:26:05 +0100 Subject: [PATCH 05/13] Rename example back to `miniforge` Signed-off-by: Julien Jerphanion --- examples/{miniforge-mamba1 => miniforge}/EULA.txt | 0 examples/{miniforge-mamba1 => miniforge}/construct.yaml | 0 examples/{miniforge-mamba1 => miniforge}/test_install.bat | 0 examples/{miniforge-mamba1 => miniforge}/test_install.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename examples/{miniforge-mamba1 => miniforge}/EULA.txt (100%) rename examples/{miniforge-mamba1 => miniforge}/construct.yaml (100%) rename examples/{miniforge-mamba1 => miniforge}/test_install.bat (100%) rename examples/{miniforge-mamba1 => miniforge}/test_install.sh (100%) diff --git a/examples/miniforge-mamba1/EULA.txt b/examples/miniforge/EULA.txt similarity index 100% rename from examples/miniforge-mamba1/EULA.txt rename to examples/miniforge/EULA.txt diff --git a/examples/miniforge-mamba1/construct.yaml b/examples/miniforge/construct.yaml similarity index 100% rename from examples/miniforge-mamba1/construct.yaml rename to examples/miniforge/construct.yaml diff --git a/examples/miniforge-mamba1/test_install.bat b/examples/miniforge/test_install.bat similarity index 100% rename from examples/miniforge-mamba1/test_install.bat rename to examples/miniforge/test_install.bat diff --git a/examples/miniforge-mamba1/test_install.sh b/examples/miniforge/test_install.sh similarity index 100% rename from examples/miniforge-mamba1/test_install.sh rename to examples/miniforge/test_install.sh From 6aee93458152369e88cec65331453205c370db25 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Mon, 3 Feb 2025 09:39:56 +0100 Subject: [PATCH 06/13] Parametrize mamba version instead Signed-off-by: Julien Jerphanion --- examples/miniforge-mamba2/EULA.txt | 28 --------- examples/miniforge-mamba2/construct.yaml | 25 -------- examples/miniforge-mamba2/test_install.bat | 8 --- examples/miniforge-mamba2/test_install.sh | 45 ------------- examples/miniforge/construct.yaml | 4 +- examples/miniforge/test_install.sh | 73 ++++++++++++++++++---- tests/test_examples.py | 4 +- 7 files changed, 66 insertions(+), 121 deletions(-) delete mode 100644 examples/miniforge-mamba2/EULA.txt delete mode 100644 examples/miniforge-mamba2/construct.yaml delete mode 100644 examples/miniforge-mamba2/test_install.bat delete mode 100644 examples/miniforge-mamba2/test_install.sh diff --git a/examples/miniforge-mamba2/EULA.txt b/examples/miniforge-mamba2/EULA.txt deleted file mode 100644 index d3bdc5b4e..000000000 --- a/examples/miniforge-mamba2/EULA.txt +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2016, Example, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Example, Inc. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL EXAMPLE, INC. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The License has to be read correctly so that dollar signs don't lead to an unset -parameter error: -You have to pay US $8, if you can read this. diff --git a/examples/miniforge-mamba2/construct.yaml b/examples/miniforge-mamba2/construct.yaml deleted file mode 100644 index cdb58f045..000000000 --- a/examples/miniforge-mamba2/construct.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Miniforge3 -version: 25.0.0 -company: conda-forge -license_file: EULA.txt - -channels: - - conda-forge - -write_condarc: True -keep_pkgs: True -transmute_file_type: .conda - -specs: - - python 3.12.* - - conda 24.11.2 - - mamba 2.0.5 - - pip - - miniforge_console_shortcut 1.* # [win] - -# Added for extra testing -installer_type: all -post_install: test_install.sh # [unix] -post_install: test_install.bat # [win] -initialize_by_default: false -register_python: False diff --git a/examples/miniforge-mamba2/test_install.bat b/examples/miniforge-mamba2/test_install.bat deleted file mode 100644 index 6f1229862..000000000 --- a/examples/miniforge-mamba2/test_install.bat +++ /dev/null @@ -1,8 +0,0 @@ -echo Added by test-install script > "%PREFIX%\test_install_sentinel.txt" -SetLocal EnableDelayedExpansion - -@ECHO ON -call "%PREFIX%\Scripts\activate.bat -conda info || exit 1 -conda config --show-sources || exit 1 -conda config --show --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert 'conda-forge' in info['channels'], info" diff --git a/examples/miniforge-mamba2/test_install.sh b/examples/miniforge-mamba2/test_install.sh deleted file mode 100644 index d5311c473..000000000 --- a/examples/miniforge-mamba2/test_install.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -set -eo pipefail -echo "Added by test-install script" > "$PREFIX/test_install_sentinel.txt" - -echo "sourcing..." -# shellcheck disable=SC1091 -source "$PREFIX/etc/profile.d/conda.sh" - -conda activate "$PREFIX" - -echo "+ conda info" -conda info -v - -echo "+ conda config" -conda config --show-sources - -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" diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index f85c4022d..d26225acf 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -1,3 +1,5 @@ +{% set mamba_version = os.environ.get("CONSTRUCTOR_TEST_MAMBA_VERSION") %} + name: Miniforge3 version: 24.11.2-1 company: conda-forge @@ -13,7 +15,7 @@ transmute_file_type: .conda specs: - python 3.12.* - conda 24.11.2 - - mamba 1.5.12 + - mamba {{ mamba_version }} - pip - miniforge_console_shortcut 1.* # [win] diff --git a/examples/miniforge/test_install.sh b/examples/miniforge/test_install.sh index d93147b51..c971a5214 100644 --- a/examples/miniforge/test_install.sh +++ b/examples/miniforge/test_install.sh @@ -19,20 +19,67 @@ 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" +# Get versions with conda +MAMBA_VERSION=$(conda list "^mamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") +LIBMAMBA_VERSION=$(conda list "^libmamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") +LIBMAMBAPY_VERSION=$(conda list "^libmambapy$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") -echo "+ mamba info" -mamba info +# Assert that their are all equal to CONSTRUCTOR_TEST_MAMBA_VERSION +if [ "$MAMBA_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then + echo "ERROR: Mamba version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $MAMBA_VERSION" + exit 1 +fi -echo "+ Testing mamba version" -mamba --version | grep mamba | cut -d' ' -f2 | grep -q 1.5.12 -mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2 +if [ "$LIBMAMBA_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then + echo "ERROR: libmamba version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $LIBMAMBA_VERSION" + exit 1 +fi -mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '1.5.12', info" -echo " OK" +if [ "$LIBMAMBAPY_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then + echo "ERROR: libmambapy version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $LIBMAMBAPY_VERSION" + exit 1 +fi -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" +MAMBA_MAJOR_VERSION=$(echo "$MAMBA_VERSION" | cut -d'.' -f1) + +# The commands and output are slightly different between mamba 1 and 2, +# so we need to test them separately. +if [ "$MAMBA_MAJOR_VERSION" -eq "1" ]; then + echo "+ Testing mamba 1 installation" + mamba --version + + echo "+ mamba info" + mamba info + + echo "+ Testing mamba version" + mamba --version | grep mamba | cut -d' ' -f2 | grep -q "$MAMBA_VERSION" + mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2 + + mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '$MAMBA_VERSION', info" + + 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" +else + echo "+ Testing mamba 2 installation" + mamba --version | grep -q "$MAMBA_VERSION" + + 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'] == '$MAMBA_VERSION', info" + + echo "+ Testing libmambapy 2 version" + python -c "import libmambapy; assert libmambapy.__version__ == '$MAMBA_VERSION', f'libmamba version got: {libmambapy.__version__}; expected: {MAMBA_VERSION}'" + + 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" +fi diff --git a/tests/test_examples.py b/tests/test_examples.py index 11b7def98..0771e6cdf 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -419,7 +419,9 @@ def test_example_extra_files(tmp_path, request): ), reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.", ) -def test_example_miniforge(tmp_path, request): +@pytest.mark.parametrize("mamba_version", ("1.5.12", "2.0.5")) +def test_example_miniforge(tmp_path, request, mamba_version, monkeypatch): + monkeypatch.setenv("CONSTRUCTOR_TEST_MAMBA_VERSION", mamba_version) input_path = _example_path("miniforge") for installer, install_dir in create_installer(input_path, tmp_path): if installer.suffix == ".sh": From 35de4ff914af2af45a28f08df66e75f6c7ae6614 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Mon, 3 Feb 2025 10:44:14 +0100 Subject: [PATCH 07/13] Update miniforge example version Signed-off-by: Julien Jerphanion --- examples/miniforge/construct.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index d26225acf..01a0aeeac 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -1,7 +1,7 @@ {% set mamba_version = os.environ.get("CONSTRUCTOR_TEST_MAMBA_VERSION") %} name: Miniforge3 -version: 24.11.2-1 +version: 25.0.0-1 company: conda-forge license_file: EULA.txt From c6cfe81a2adff5c67e8e069981a83291a387759b Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 4 Feb 2025 09:54:57 +0100 Subject: [PATCH 08/13] Duplicate example based on mamba version Signed-off-by: Julien Jerphanion --- examples/miniforge-mamba2/EULA.txt | 28 ++++++++++ examples/miniforge-mamba2/construct.yaml | 25 +++++++++ examples/miniforge-mamba2/test_install.bat | 8 +++ examples/miniforge-mamba2/test_install.sh | 64 +++++++++++++++++++++ examples/miniforge/construct.yaml | 4 +- examples/miniforge/test_install.sh | 65 +++++++--------------- tests/test_examples.py | 7 +-- 7 files changed, 148 insertions(+), 53 deletions(-) create mode 100644 examples/miniforge-mamba2/EULA.txt create mode 100644 examples/miniforge-mamba2/construct.yaml create mode 100644 examples/miniforge-mamba2/test_install.bat create mode 100644 examples/miniforge-mamba2/test_install.sh diff --git a/examples/miniforge-mamba2/EULA.txt b/examples/miniforge-mamba2/EULA.txt new file mode 100644 index 000000000..d3bdc5b4e --- /dev/null +++ b/examples/miniforge-mamba2/EULA.txt @@ -0,0 +1,28 @@ +Copyright (c) 2016, Example, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Example, Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL EXAMPLE, INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The License has to be read correctly so that dollar signs don't lead to an unset +parameter error: +You have to pay US $8, if you can read this. diff --git a/examples/miniforge-mamba2/construct.yaml b/examples/miniforge-mamba2/construct.yaml new file mode 100644 index 000000000..aef36a069 --- /dev/null +++ b/examples/miniforge-mamba2/construct.yaml @@ -0,0 +1,25 @@ +name: Miniforge3 +version: 25.0.0-1 +company: conda-forge +license_file: EULA.txt + +channels: + - conda-forge + +write_condarc: True +keep_pkgs: True +transmute_file_type: .conda + +specs: + - python 3.12.* + - conda 24.11.2 + - mamba 2.0.5 + - pip + - miniforge_console_shortcut 1.* # [win] + +# Added for extra testing +installer_type: all +post_install: test_install.sh # [unix] +post_install: test_install.bat # [win] +initialize_by_default: false +register_python: False diff --git a/examples/miniforge-mamba2/test_install.bat b/examples/miniforge-mamba2/test_install.bat new file mode 100644 index 000000000..6f1229862 --- /dev/null +++ b/examples/miniforge-mamba2/test_install.bat @@ -0,0 +1,8 @@ +echo Added by test-install script > "%PREFIX%\test_install_sentinel.txt" +SetLocal EnableDelayedExpansion + +@ECHO ON +call "%PREFIX%\Scripts\activate.bat +conda info || exit 1 +conda config --show-sources || exit 1 +conda config --show --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert 'conda-forge' in info['channels'], info" diff --git a/examples/miniforge-mamba2/test_install.sh b/examples/miniforge-mamba2/test_install.sh new file mode 100644 index 000000000..701049721 --- /dev/null +++ b/examples/miniforge-mamba2/test_install.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -eo pipefail +echo "Added by test-install script" > "$PREFIX/test_install_sentinel.txt" + +echo "sourcing..." +# shellcheck disable=SC1091 +source "$PREFIX/etc/profile.d/conda.sh" + +conda activate "$PREFIX" + +echo "+ conda info" +conda info -v + +echo "+ conda config" +conda config --show-sources + +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" + +EXPECTED_MAMBA_VERSION="2.0.5" + +# Get versions with conda +MAMBA_VERSION=$(conda list "^mamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") +LIBMAMBA_VERSION=$(conda list "^libmamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") +LIBMAMBAPY_VERSION=$(conda list "^libmambapy$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") + +if [ "$MAMBA_VERSION" != "$EXPECTED_MAMBA_VERSION" ]; then + echo "ERROR: Mamba version mismatch: expected $EXPECTED_MAMBA_VERSION, got $MAMBA_VERSION" + exit 1 +fi + +if [ "$LIBMAMBA_VERSION" != "$EXPECTED_MAMBA_VERSION" ]; then + echo "ERROR: libmamba version mismatch: expected $EXPECTED_MAMBA_VERSION, got $LIBMAMBA_VERSION" + exit 1 +fi + +if [ "$LIBMAMBAPY_VERSION" != "$EXPECTED_MAMBA_VERSION" ]; then + echo "ERROR: libmambapy version mismatch: expected $EXPECTED_MAMBA_VERSION, got $LIBMAMBAPY_VERSION" + exit 1 +fi + +echo "+ Testing mamba 2 installation" +mamba --version | grep -q "$EXPECTED_MAMBA_VERSION" + +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'] == '$EXPECTED_MAMBA_VERSION', info" + +echo "+ Testing libmambapy 2 version" +python -c "import libmambapy; assert libmambapy.__version__ == '$EXPECTED_MAMBA_VERSION', f'libmamba version got: {libmambapy.__version__}; expected: ${EXPECTED_MAMBA_VERSION}'" + +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" diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index 01a0aeeac..040f111a0 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -1,5 +1,3 @@ -{% set mamba_version = os.environ.get("CONSTRUCTOR_TEST_MAMBA_VERSION") %} - name: Miniforge3 version: 25.0.0-1 company: conda-forge @@ -15,7 +13,7 @@ transmute_file_type: .conda specs: - python 3.12.* - conda 24.11.2 - - mamba {{ mamba_version }} + - mamba 1.5.12 - pip - miniforge_console_shortcut 1.* # [win] diff --git a/examples/miniforge/test_install.sh b/examples/miniforge/test_install.sh index c971a5214..de7a273ed 100644 --- a/examples/miniforge/test_install.sh +++ b/examples/miniforge/test_install.sh @@ -19,67 +19,40 @@ 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" +EXPECTED_MAMBA_VERSION="1.5.12" + # Get versions with conda MAMBA_VERSION=$(conda list "^mamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") LIBMAMBA_VERSION=$(conda list "^libmamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") LIBMAMBAPY_VERSION=$(conda list "^libmambapy$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])") -# Assert that their are all equal to CONSTRUCTOR_TEST_MAMBA_VERSION -if [ "$MAMBA_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then - echo "ERROR: Mamba version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $MAMBA_VERSION" +if [ "$MAMBA_VERSION" != "$EXPECTED_MAMBA_VERSION" ]; then + echo "ERROR: Mamba version mismatch: expected $EXPECTED_MAMBA_VERSION, got $MAMBA_VERSION" exit 1 fi -if [ "$LIBMAMBA_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then - echo "ERROR: libmamba version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $LIBMAMBA_VERSION" +if [ "$LIBMAMBA_VERSION" != "$EXPECTED_MAMBA_VERSION" ]; then + echo "ERROR: libmamba version mismatch: expected $EXPECTED_MAMBA_VERSION, got $LIBMAMBA_VERSION" exit 1 fi -if [ "$LIBMAMBAPY_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then - echo "ERROR: libmambapy version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $LIBMAMBAPY_VERSION" +if [ "$LIBMAMBAPY_VERSION" != "$EXPECTED_MAMBA_VERSION" ]; then + echo "ERROR: libmambapy version mismatch: expected $EXPECTED_MAMBA_VERSION, got $LIBMAMBAPY_VERSION" exit 1 fi -MAMBA_MAJOR_VERSION=$(echo "$MAMBA_VERSION" | cut -d'.' -f1) - -# The commands and output are slightly different between mamba 1 and 2, -# so we need to test them separately. -if [ "$MAMBA_MAJOR_VERSION" -eq "1" ]; then - echo "+ Testing mamba 1 installation" - mamba --version - - echo "+ mamba info" - mamba info - - echo "+ Testing mamba version" - mamba --version | grep mamba | cut -d' ' -f2 | grep -q "$MAMBA_VERSION" - mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2 - - mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '$MAMBA_VERSION', info" +echo "+ Testing mamba 1 installation" +mamba --version - 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" -else - echo "+ Testing mamba 2 installation" - mamba --version | grep -q "$MAMBA_VERSION" +echo "+ mamba info" +mamba info - echo "+ mamba info" - mamba info +echo "+ Testing mamba version" +mamba --version | grep mamba | cut -d' ' -f2 | grep -q "$EXPECTED_MAMBA_VERSION" +mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2 - echo "+ mamba config sources" - mamba config sources +mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '$EXPECTED_MAMBA_VERSION', info" - 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'] == '$MAMBA_VERSION', info" - - echo "+ Testing libmambapy 2 version" - python -c "import libmambapy; assert libmambapy.__version__ == '$MAMBA_VERSION', f'libmamba version got: {libmambapy.__version__}; expected: {MAMBA_VERSION}'" - - 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" -fi +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" diff --git a/tests/test_examples.py b/tests/test_examples.py index 0771e6cdf..6c3b6951e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -419,10 +419,9 @@ def test_example_extra_files(tmp_path, request): ), reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.", ) -@pytest.mark.parametrize("mamba_version", ("1.5.12", "2.0.5")) -def test_example_miniforge(tmp_path, request, mamba_version, monkeypatch): - monkeypatch.setenv("CONSTRUCTOR_TEST_MAMBA_VERSION", mamba_version) - input_path = _example_path("miniforge") +@pytest.mark.parametrize("example", ("miniforge", "miniforge-mamba2")) +def test_example_miniforge(tmp_path, request, monkeypatch, example): + input_path = _example_path(example) for installer, install_dir in create_installer(input_path, tmp_path): if installer.suffix == ".sh": # try both batch and interactive installations From 6e0da50c8ddf318f893b1c4dde37ead271774386 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 4 Feb 2025 13:43:58 +0100 Subject: [PATCH 09/13] Bump version number for miniforge-mamba2 Signed-off-by: Julien Jerphanion --- examples/miniforge-mamba2/construct.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/miniforge-mamba2/construct.yaml b/examples/miniforge-mamba2/construct.yaml index aef36a069..747652624 100644 --- a/examples/miniforge-mamba2/construct.yaml +++ b/examples/miniforge-mamba2/construct.yaml @@ -1,5 +1,5 @@ name: Miniforge3 -version: 25.0.0-1 +version: 25.0.0-2 company: conda-forge license_file: EULA.txt From f20ea51df504d0bfff561f41cf7e17459b6a4e84 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 4 Feb 2025 17:42:44 +0100 Subject: [PATCH 10/13] Add teardown of the installers and their install directories Signed-off-by: Julien Jerphanion --- tests/test_examples.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_examples.py b/tests/test_examples.py index 6c3b6951e..f82367e89 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -355,6 +355,10 @@ def _sort_by_extension(path): except shutil.Error: # Some tests reuse the examples for different checks; ignore errors pass + else: + # Remove the installer and the install dir at the end of the test + shutil.rmtree(str(installer), ignore_errors=True) + shutil.rmtree(str(install_dir), ignore_errors=True) @lru_cache(maxsize=None) From 646cf345e86a13400a77c827fa1289f37914deb1 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Wed, 5 Feb 2025 08:17:06 +0100 Subject: [PATCH 11/13] Specify `default_location_pkg` for both examples Signed-off-by: Julien Jerphanion --- examples/miniforge-mamba2/construct.yaml | 1 + examples/miniforge/construct.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/miniforge-mamba2/construct.yaml b/examples/miniforge-mamba2/construct.yaml index 747652624..d98f3794c 100644 --- a/examples/miniforge-mamba2/construct.yaml +++ b/examples/miniforge-mamba2/construct.yaml @@ -1,5 +1,6 @@ name: Miniforge3 version: 25.0.0-2 +default_location_pkg: Library/Miniforge3-25.0.0-2 company: conda-forge license_file: EULA.txt diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index 040f111a0..6910f90ed 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -1,5 +1,6 @@ name: Miniforge3 version: 25.0.0-1 +default_location_pkg: Library/Miniforge3-25.0.0-1 company: conda-forge license_file: EULA.txt From 8c357b3c1ba1be8b8631f66dc761e9939e7951ad Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Wed, 5 Feb 2025 08:41:48 +0100 Subject: [PATCH 12/13] Simply change name Signed-off-by: Julien Jerphanion --- examples/miniforge-mamba2/construct.yaml | 3 +-- examples/miniforge/construct.yaml | 1 - tests/test_examples.py | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/miniforge-mamba2/construct.yaml b/examples/miniforge-mamba2/construct.yaml index d98f3794c..24eb4a512 100644 --- a/examples/miniforge-mamba2/construct.yaml +++ b/examples/miniforge-mamba2/construct.yaml @@ -1,6 +1,5 @@ -name: Miniforge3 +name: Miniforge3-mamba2 version: 25.0.0-2 -default_location_pkg: Library/Miniforge3-25.0.0-2 company: conda-forge license_file: EULA.txt diff --git a/examples/miniforge/construct.yaml b/examples/miniforge/construct.yaml index 6910f90ed..040f111a0 100644 --- a/examples/miniforge/construct.yaml +++ b/examples/miniforge/construct.yaml @@ -1,6 +1,5 @@ name: Miniforge3 version: 25.0.0-1 -default_location_pkg: Library/Miniforge3-25.0.0-1 company: conda-forge license_file: EULA.txt diff --git a/tests/test_examples.py b/tests/test_examples.py index f82367e89..62aa01570 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -446,7 +446,8 @@ def test_example_miniforge(tmp_path, request, monkeypatch, example): uninstall=False, ) if installer.suffix == ".pkg" and ON_CI: - _sentinel_file_checks(input_path, Path(os.environ["HOME"]) / "Miniforge3") + basename = "Miniforge3" if example == "miniforge" else "Miniforge3-mamba2" + _sentinel_file_checks(input_path, Path(os.environ["HOME"]) / basename) if installer.suffix == ".exe": for key in ("ProgramData", "AppData"): start_menu_dir = Path( From 9d490c3b050ada723a735f87c0f06bc237e62526 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 11 Feb 2025 08:29:50 +0100 Subject: [PATCH 13/13] Address review comments Signed-off-by: Julien Jerphanion Co-authored-by: Marco Esters --- news/936-version-parsing-mamba-1 | 2 +- tests/test_examples.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/news/936-version-parsing-mamba-1 b/news/936-version-parsing-mamba-1 index de770a5c5..7c9edeae8 100644 --- a/news/936-version-parsing-mamba-1 +++ b/news/936-version-parsing-mamba-1 @@ -4,7 +4,7 @@ ### Bug fixes -* Fix version parsing when mamba 1 is used (#936) +* Fix version parsing when `mamba` v1 is used (#936) ### Deprecations diff --git a/tests/test_examples.py b/tests/test_examples.py index 62aa01570..1e4afd694 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -355,10 +355,6 @@ def _sort_by_extension(path): except shutil.Error: # Some tests reuse the examples for different checks; ignore errors pass - else: - # Remove the installer and the install dir at the end of the test - shutil.rmtree(str(installer), ignore_errors=True) - shutil.rmtree(str(install_dir), ignore_errors=True) @lru_cache(maxsize=None) @@ -424,7 +420,7 @@ def test_example_extra_files(tmp_path, request): reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.", ) @pytest.mark.parametrize("example", ("miniforge", "miniforge-mamba2")) -def test_example_miniforge(tmp_path, request, monkeypatch, example): +def test_example_miniforge(tmp_path, request, example): input_path = _example_path(example) for installer, install_dir in create_installer(input_path, tmp_path): if installer.suffix == ".sh": @@ -440,6 +436,7 @@ def test_example_miniforge(tmp_path, request, monkeypatch, example): installer, install_dir, installer_input=installer_input, + request=request, # PKG installers use their own install path, so we can't check sentinels # via `install_dir` check_sentinels=installer.suffix != ".pkg",