diff --git a/constructor/header.sh b/constructor/header.sh index 129d3da95..2edb0ca44 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -461,11 +461,15 @@ 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_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ + CONDA_PKGS_DIRS="$(mktemp -d)" \ + "$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 6d59d60a8..35f7b3e17 100644 --- a/constructor/osx/prepare_installation.sh +++ b/constructor/osx/prepare_installation.sh @@ -35,11 +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... do it in a temporary location # shellcheck disable=SC2050 if [ "__VIRTUAL_SPECS__" != "" ]; then - CONDA_QUIET="$BATCH" \ + notify 'Checking virtual specs compatibility: __VIRTUAL_SPECS__' CONDA_SOLVER="classic" \ - "$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ + CONDA_PKGS_DIRS="$(mktemp -d)" \ + "$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/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..e92e61f49 --- /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/news/843-conda-pkgs-dirs-virtual-specs b/news/843-conda-pkgs-dirs-virtual-specs new file mode 100644 index 000000000..b11a67003 --- /dev/null +++ b/news/843-conda-pkgs-dirs-virtual-specs @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* 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 + +* + +### Docs + +* + +### Other + +* 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, + )