From ad2fbcde9b5b126c0edbadd5531d94348dca65cd Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 14 Aug 2024 17:44:11 +0200 Subject: [PATCH 01/11] Add tests for successful virtual_specs checks --- .../construct.yaml | 2 +- examples/virtual_specs_ok/construct.yaml | 22 +++++++++++++++++++ tests/test_examples.py | 17 ++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) rename examples/{virtual_specs => virtual_specs_failed}/construct.yaml (91%) create mode 100644 examples/virtual_specs_ok/construct.yaml diff --git a/examples/virtual_specs/construct.yaml b/examples/virtual_specs_failed/construct.yaml similarity index 91% rename from examples/virtual_specs/construct.yaml rename to examples/virtual_specs_failed/construct.yaml index 7b04c0b6a..0b8eae288 100644 --- a/examples/virtual_specs/construct.yaml +++ b/examples/virtual_specs_failed/construct.yaml @@ -1,4 +1,4 @@ -name: virtual_specs +name: virtual_specs_failed version: 0.0.1 diff --git a/examples/virtual_specs_ok/construct.yaml b/examples/virtual_specs_ok/construct.yaml new file mode 100644 index 000000000..7343a3b9f --- /dev/null +++ b/examples/virtual_specs_ok/construct.yaml @@ -0,0 +1,22 @@ +name: virtual_specs_ok + +version: 0.0.1 + +keep_pkgs: True + +channels: + - conda-forge + +specs: + - ca-certificates + +virtual_specs: + - __osx>=10.9 # [osx] + - __glibc>=2.12 # [linux] + - __win>0 # [win] + +initialize_by_default: false +register_python: false +check_path_spaces: false +check_path_length: false +installer_type: all diff --git a/tests/test_examples.py b/tests/test_examples.py index 7a0975799..2fcfcf753 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -693,8 +693,8 @@ def test_cross_osx_building(tmp_path): ) -def test_virtual_specs(tmp_path, request): - input_path = _example_path("virtual_specs") +def test_virtual_specs_failed(tmp_path, request): + input_path = _example_path("virtual_specs_failed") for installer, install_dir in create_installer(input_path, tmp_path): process = _run_installer( input_path, @@ -720,3 +720,16 @@ def test_virtual_specs(tmp_path, request): msg = "Installer requires" assert process.returncode != 0 assert msg in process.stdout + process.stderr + + +def test_virtual_specs_ok(tmp_path, request): + input_path = _example_path("virtual_specs_ok") + for installer, install_dir in create_installer(input_path, tmp_path): + _run_installer( + input_path, + installer, + install_dir, + request=request, + check_subprocess=True, + uninstall=True, + ) From a3568da0f1a8b3a751f47db8be0f9ec4c935c908 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 14 Aug 2024 17:57:33 +0200 Subject: [PATCH 02/11] add news --- news/843-conda-pkgs-dirs-virtual-specs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/843-conda-pkgs-dirs-virtual-specs diff --git a/news/843-conda-pkgs-dirs-virtual-specs b/news/843-conda-pkgs-dirs-virtual-specs new file mode 100644 index 000000000..0319b47f7 --- /dev/null +++ b/news/843-conda-pkgs-dirs-virtual-specs @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Set `CONDA_PKGS_DIRS` for the micromamba-driven `virtual_specs` checks. (#843) + +### Deprecations + +* + +### Docs + +* + +### Other + +* From df1746f78984415db11cd6ef6f10af9a0b8a275d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 14 Aug 2024 18:03:33 +0200 Subject: [PATCH 03/11] set CONDA_PKGS_DIRS on unix --- constructor/header.sh | 1 + constructor/osx/prepare_installation.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/constructor/header.sh b/constructor/header.sh index 129d3da95..bc5229d02 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -465,6 +465,7 @@ mkdir -p "$TMP" if [ "__VIRTUAL_SPECS__" != "" ]; then CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ + CONDA_PKGS_DIRS="$PREFIX/pkgs" \ "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ fi diff --git a/constructor/osx/prepare_installation.sh b/constructor/osx/prepare_installation.sh index 6d59d60a8..5ab54a5e5 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -39,6 +39,7 @@ touch "$PREFIX/conda-meta/history" if [ "__VIRTUAL_SPECS__" != "" ]; then CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ + CONDA_PKGS_DIRS="$PREFIX/pkgs" \ "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ fi From 5aa31f45b29c59da1e9082ce78d2c07d0f7637bf Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 14 Aug 2024 18:06:21 +0200 Subject: [PATCH 04/11] echo some info --- constructor/header.sh | 1 + constructor/osx/prepare_installation.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/constructor/header.sh b/constructor/header.sh index bc5229d02..50be019f9 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -463,6 +463,7 @@ mkdir -p "$TMP" # https://github.com/conda/conda-libmamba-solver/issues/480 # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then + echo 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ CONDA_PKGS_DIRS="$PREFIX/pkgs" \ diff --git a/constructor/osx/prepare_installation.sh b/constructor/osx/prepare_installation.sh index 5ab54a5e5..b2dde9935 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -37,6 +37,7 @@ touch "$PREFIX/conda-meta/history" # https://github.com/conda/conda-libmamba-solver/issues/480 # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then + echo 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ CONDA_PKGS_DIRS="$PREFIX/pkgs" \ From c289e6b03ba01254ff54f78918ef527693cd5e90 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 14 Aug 2024 18:22:16 +0200 Subject: [PATCH 05/11] use temp location? --- constructor/header.sh | 4 +++- constructor/osx/prepare_installation.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/constructor/header.sh b/constructor/header.sh index 50be019f9..e207d7e9e 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -461,12 +461,14 @@ mkdir -p "$TMP" # We need to specify CONDA_SOLVER=classic for conda-standalone # to work around this bug in conda-libmamba-solver: # https://github.com/conda/conda-libmamba-solver/issues/480 +# micromamba needs an existing pkgs_dir to operate even offline, +# but we haven't created $PREFIX/pkgs yet... give it a temp location # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then echo 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ - CONDA_PKGS_DIRS="$PREFIX/pkgs" \ + CONDA_PKGS_DIRS="$(mktemp -d)" \ "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ fi diff --git a/constructor/osx/prepare_installation.sh b/constructor/osx/prepare_installation.sh index b2dde9935..3b93d4bc9 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -35,12 +35,14 @@ touch "$PREFIX/conda-meta/history" # We need to specify CONDA_SOLVER=classic for conda-standalone # to work around this bug in conda-libmamba-solver: # https://github.com/conda/conda-libmamba-solver/issues/480 +# micromamba needs an existing pkgs_dir to operate even offline, +# but we haven't created $PREFIX/pkgs yet... give it a temp location # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then echo 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ - CONDA_PKGS_DIRS="$PREFIX/pkgs" \ + CONDA_PKGS_DIRS="$(mktemp -d)" \ "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ fi From a5e83433f7b5550e3446a16fb474c2a3dceac10d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 15 Aug 2024 13:00:38 +0200 Subject: [PATCH 06/11] use PREFIX/pkgs for PKG installers --- constructor/osx/prepare_installation.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/constructor/osx/prepare_installation.sh b/constructor/osx/prepare_installation.sh index 3b93d4bc9..b4c49fc59 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -36,13 +36,14 @@ touch "$PREFIX/conda-meta/history" # to work around this bug in conda-libmamba-solver: # https://github.com/conda/conda-libmamba-solver/issues/480 # micromamba needs an existing pkgs_dir to operate even offline, -# but we haven't created $PREFIX/pkgs yet... give it a temp location +# but we haven't created $PREFIX/pkgs yet... do it now # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then - echo 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' + notify 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' + mkdir -p "$PREFIX/pkgs" CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ - CONDA_PKGS_DIRS="$(mktemp -d)" \ + CONDA_PKGS_DIRS="$PREFIX/pkgs" \ "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ fi From f41a89094c06e29b30b39c73093a57dbdb5a2b4f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 15 Aug 2024 13:48:30 +0200 Subject: [PATCH 07/11] $BATCH is undefined in PKG --- constructor/osx/prepare_installation.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/constructor/osx/prepare_installation.sh b/constructor/osx/prepare_installation.sh index b4c49fc59..a631547d3 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -36,14 +36,12 @@ touch "$PREFIX/conda-meta/history" # to work around this bug in conda-libmamba-solver: # https://github.com/conda/conda-libmamba-solver/issues/480 # micromamba needs an existing pkgs_dir to operate even offline, -# but we haven't created $PREFIX/pkgs yet... do it now +# but we haven't created $PREFIX/pkgs yet... do it in a temporary location # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then notify 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' - mkdir -p "$PREFIX/pkgs" - CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ - CONDA_PKGS_DIRS="$PREFIX/pkgs" \ + CONDA_PKGS_DIRS="$(mktemp -d)" \ "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ fi From 1958d383ff573113b8e95603df475ebc4f00602f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 15 Aug 2024 13:49:09 +0200 Subject: [PATCH 08/11] update win example --- examples/virtual_specs_ok/construct.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/virtual_specs_ok/construct.yaml b/examples/virtual_specs_ok/construct.yaml index 7343a3b9f..e92e61f49 100644 --- a/examples/virtual_specs_ok/construct.yaml +++ b/examples/virtual_specs_ok/construct.yaml @@ -13,7 +13,7 @@ specs: virtual_specs: - __osx>=10.9 # [osx] - __glibc>=2.12 # [linux] - - __win>0 # [win] + - __win>=0 # [win] initialize_by_default: false register_python: false From 3078cf2bc16dfba26ada92fb52fac97ba4d12bfb Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 15 Aug 2024 13:53:19 +0200 Subject: [PATCH 09/11] amend news --- news/843-conda-pkgs-dirs-virtual-specs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/843-conda-pkgs-dirs-virtual-specs b/news/843-conda-pkgs-dirs-virtual-specs index 0319b47f7..e71e07a70 100644 --- a/news/843-conda-pkgs-dirs-virtual-specs +++ b/news/843-conda-pkgs-dirs-virtual-specs @@ -4,7 +4,7 @@ ### Bug fixes -* Set `CONDA_PKGS_DIRS` for the micromamba-driven `virtual_specs` checks. (#843) +* Fix a couple issues in the `virtual_specs` feature (set `CONDA_PKGS_DIRS` for `micromamba`, do not rely `$BATCH` for PKG, update the Windows example). (#843) ### Deprecations From b6ef866967b545684cf10b9af534140542d71ad1 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 15 Aug 2024 14:52:54 +0200 Subject: [PATCH 10/11] Point to a non-PREFIX place --- constructor/header.sh | 2 +- constructor/nsis/main.nsi.tmpl | 2 +- constructor/osx/prepare_installation.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/constructor/header.sh b/constructor/header.sh index e207d7e9e..2edb0ca44 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -469,7 +469,7 @@ if [ "__VIRTUAL_SPECS__" != "" ]; then CONDA_QUIET="$BATCH" \ CONDA_SOLVER="classic" \ CONDA_PKGS_DIRS="$(mktemp -d)" \ - "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ + "$CONDA_EXEC" create --dry-run --prefix "$PREFIX/envs/_virtual_specs_checks" --offline __VIRTUAL_SPECS__ fi # Create $PREFIX/.nonadmin if the installation didn't require superuser permissions diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index 96190cf6e..133904460 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -1139,7 +1139,7 @@ Section "Install" System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_SOLVER", "classic").r0' SetDetailsPrint TextOnly DetailPrint "Checking virtual specs..." - push '"$INSTDIR\_conda.exe" create --dry-run --prefix "$INSTDIR" --offline @VIRTUAL_SPECS@' + push '"$INSTDIR\_conda.exe" create --dry-run --prefix "$INSTDIR\envs\_virtual_specs_checks" --offline @VIRTUAL_SPECS@' push 'Failed to check virtual specs: @VIRTUAL_SPECS@' push 'WithLog' call AbortRetryNSExecWait diff --git a/constructor/osx/prepare_installation.sh b/constructor/osx/prepare_installation.sh index a631547d3..35f7b3e17 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -42,7 +42,7 @@ if [ "__VIRTUAL_SPECS__" != "" ]; then notify 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' CONDA_SOLVER="classic" \ CONDA_PKGS_DIRS="$(mktemp -d)" \ - "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ + "$CONDA_EXEC" create --dry-run --prefix "$PREFIX/envs/_virtual_specs_checks" --offline __VIRTUAL_SPECS__ fi # Create $PREFIX/.nonadmin if the installation didn't require superuser permissions From 99f8d66484f050674f18ac300b9562e4ce65acbd Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Thu, 15 Aug 2024 08:48:33 -0700 Subject: [PATCH 11/11] Update news/843-conda-pkgs-dirs-virtual-specs --- news/843-conda-pkgs-dirs-virtual-specs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/843-conda-pkgs-dirs-virtual-specs b/news/843-conda-pkgs-dirs-virtual-specs index e71e07a70..b11a67003 100644 --- a/news/843-conda-pkgs-dirs-virtual-specs +++ b/news/843-conda-pkgs-dirs-virtual-specs @@ -4,7 +4,7 @@ ### Bug fixes -* Fix a couple issues in the `virtual_specs` feature (set `CONDA_PKGS_DIRS` for `micromamba`, do not rely `$BATCH` for PKG, update the Windows example). (#843) +* Fix a couple issues in the `virtual_specs` feature (set `CONDA_PKGS_DIRS` for `micromamba`, do not rely on `$BATCH` for PKG, update the Windows example). (#843) ### Deprecations