|
21 | 21 | from conda.models.version import VersionOrder as Version |
22 | 22 | from ruamel.yaml import YAML |
23 | 23 |
|
24 | | -from constructor.utils import StandaloneExe, identify_conda_exe |
| 24 | +from constructor.utils import StandaloneExe, check_version, identify_conda_exe |
25 | 25 |
|
26 | 26 | if TYPE_CHECKING: |
27 | 27 | from collections.abc import Generator, Iterable |
@@ -317,6 +317,9 @@ def _run_installer( |
317 | 317 | check=check_subprocess, |
318 | 318 | options=options, |
319 | 319 | ) |
| 320 | + if request and ON_CI: |
| 321 | + # GitHub runners run out of disk space if installation directories are not cleaned up |
| 322 | + request.addfinalizer(lambda: shutil.rmtree(str(install_dir), ignore_errors=True)) |
320 | 323 | elif installer.suffix == ".pkg": |
321 | 324 | if request and ON_CI: |
322 | 325 | request.addfinalizer(lambda: shutil.rmtree(str(install_dir), ignore_errors=True)) |
@@ -512,8 +515,7 @@ def test_example_mirrored_channels(tmp_path, request): |
512 | 515 | @pytest.mark.xfail( |
513 | 516 | ( |
514 | 517 | CONDA_EXE == StandaloneExe.CONDA |
515 | | - and CONDA_EXE_VERSION is not None |
516 | | - and CONDA_EXE_VERSION < Version("23.11.0a0") |
| 518 | + and not check_version(CONDA_EXE_VERSION, min_version="23.11.0a0") |
517 | 519 | ), |
518 | 520 | reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.", |
519 | 521 | ) |
@@ -693,8 +695,7 @@ def test_example_scripts(tmp_path, request): |
693 | 695 | @pytest.mark.skipif( |
694 | 696 | ( |
695 | 697 | CONDA_EXE == StandaloneExe.MAMBA |
696 | | - or CONDA_EXE_VERSION is None |
697 | | - or CONDA_EXE_VERSION < Version("23.11.0a0") |
| 698 | + and not check_version(CONDA_EXE_VERSION, min_version="23.11.0a0") |
698 | 699 | ), |
699 | 700 | reason="menuinst v2 requires conda-standalone>=23.11.0; micromamba is not supported yet", |
700 | 701 | ) |
@@ -1218,7 +1219,7 @@ def _get_dacl_information(filepath: Path) -> dict: |
1218 | 1219 |
|
1219 | 1220 |
|
1220 | 1221 | @pytest.mark.xfail( |
1221 | | - CONDA_EXE == StandaloneExe.CONDA and CONDA_EXE_VERSION < Version("24.9.0"), |
| 1222 | + CONDA_EXE == StandaloneExe.CONDA and not check_version(CONDA_EXE_VERSION, min_version="24.9.0"), |
1222 | 1223 | reason="Pre-existing .condarc breaks installation", |
1223 | 1224 | ) |
1224 | 1225 | def test_ignore_condarc_files(tmp_path, monkeypatch, request): |
@@ -1268,7 +1269,7 @@ def test_ignore_condarc_files(tmp_path, monkeypatch, request): |
1268 | 1269 |
|
1269 | 1270 |
|
1270 | 1271 | @pytest.mark.skipif( |
1271 | | - CONDA_EXE == StandaloneExe.CONDA and CONDA_EXE_VERSION < Version("24.11.0"), |
| 1272 | + CONDA_EXE == StandaloneExe.CONDA and check_version(CONDA_EXE_VERSION, min_version="24.11.0"), |
1272 | 1273 | reason="Requires conda-standalone 24.11.x or newer", |
1273 | 1274 | ) |
1274 | 1275 | @pytest.mark.skipif(not sys.platform == "win32", reason="Windows only") |
@@ -1369,6 +1370,39 @@ def test_output_files(tmp_path): |
1369 | 1370 | assert files_exist == [] |
1370 | 1371 |
|
1371 | 1372 |
|
| 1373 | +@pytest.mark.xfail( |
| 1374 | + condition=( |
| 1375 | + CONDA_EXE == StandaloneExe.CONDA |
| 1376 | + and check_version(CONDA_EXE_VERSION, min_version="25.5.0", max_version="25.7.0") |
| 1377 | + ), |
| 1378 | + reason="conda-standalone 25.5.x fails with protected environments", |
| 1379 | + strict=True, |
| 1380 | +) |
| 1381 | +def test_frozen_environment(tmp_path, request): |
| 1382 | + input_path = _example_path("protected_base") |
| 1383 | + for installer, install_dir in create_installer(input_path, tmp_path): |
| 1384 | + _run_installer( |
| 1385 | + input_path, |
| 1386 | + installer, |
| 1387 | + install_dir, |
| 1388 | + request=request, |
| 1389 | + uninstall=False, |
| 1390 | + ) |
| 1391 | + |
| 1392 | + expected_frozen_paths = { |
| 1393 | + install_dir / "conda-meta" / "frozen", |
| 1394 | + install_dir / "envs" / "default" / "conda-meta" / "frozen", |
| 1395 | + } |
| 1396 | + |
| 1397 | + actual_frozen_paths = set() |
| 1398 | + for env in install_dir.glob("**/conda-meta/history"): |
| 1399 | + frozen_file = env.parent / "frozen" |
| 1400 | + if frozen_file.exists(): |
| 1401 | + actual_frozen_paths.add(frozen_file) |
| 1402 | + |
| 1403 | + assert expected_frozen_paths == actual_frozen_paths |
| 1404 | + |
| 1405 | + |
1372 | 1406 | def test_regressions(tmp_path, request): |
1373 | 1407 | input_path = _example_path("regressions") |
1374 | 1408 | for installer, install_dir in create_installer(input_path, tmp_path): |
|
0 commit comments