diff --git a/constructor/main.py b/constructor/main.py index e4d8c897..bee9f081 100644 --- a/constructor/main.py +++ b/constructor/main.py @@ -187,26 +187,27 @@ def main_build(dir_path, output_dir='.', platform=cc_platform, else: env_config[config_key] = value - if exe_type is None or exe_version is None: - logger.warning( - "Could not identify conda-standalone / micromamba version. " - "Will assume it is compatible with shortcuts." + # Installers will disable shortcut options and features only if the user + # opted-out by setting every `menu_packages` item to an empty list + info['_enable_shortcuts'] = bool( + info.get("menu_packages", True) + or any( + env.get("menu_packages", True) + for env in info.get("extra_envs", {}).values() ) - elif sys.platform != "win32" and ( - exe_type != StandaloneExe.CONDA or (exe_version and exe_version < Version("23.11.0")) - ): - logger.warning("conda-standalone 23.11.0 or above is required for shortcuts on Unix.") - info['_enable_shortcuts'] = "incompatible" - else: - # Installers will provide shortcut options and features only if the user - # didn't opt-out by setting every `menu_packages` item to an empty list - info['_enable_shortcuts'] = bool( - info.get("menu_packages", True) - or any( - env.get("menu_packages", True) - for env in info.get("extra_envs", {}).values() + ) + + if info['_enable_shortcuts']: + if exe_type is None or exe_version is None: + logger.warning( + "Could not identify conda-standalone / micromamba version. " + "Will assume it is compatible with shortcuts." ) - ) + elif sys.platform != "win32" and ( + exe_type != StandaloneExe.CONDA or (exe_version and exe_version < Version("23.11.0")) + ): + logger.warning("conda-standalone 23.11.0 or above is required for shortcuts on Unix.") + info['_enable_shortcuts'] = "incompatible" # Add --no-rc option to CONDA_EXE command so that existing # .condarc files do not pollute the installation process. diff --git a/constructor/utils.py b/constructor/utils.py index 4b2c6352..018bab08 100644 --- a/constructor/utils.py +++ b/constructor/utils.py @@ -302,7 +302,7 @@ def identify_conda_exe(conda_exe: Union[str, Path] = None) -> Tuple[StandaloneEx output_help = check_output([conda_exe, "--help"], text=True) if "mamba" in output_help: return StandaloneExe.MAMBA, output_version - except CalledProcessError as exc: + except (CalledProcessError, OSError) as exc: logger.warning(f"Could not identify standalone binary {exc}.") return None, None diff --git a/tests/test_examples.py b/tests/test_examples.py index 3fb7308d..eddeef64 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -741,6 +741,42 @@ def test_example_from_env_yaml(tmp_path, request): assert pkg["channel"] != "pypi" +@pytest.fixture(params=["linux-aarch64"]) +def platform_conda_exe(request, tmp_path) -> Tuple[str, Path]: + platform = request.param + tmp_env = tmp_path / "env" + subprocess.check_call( + [ + sys.executable, + "-mconda", + "create", + "-p", + tmp_env, + "-y", + "conda-standalone", + "--platform", + platform, + ], + ) + conda_exe = tmp_env / "conda_standalone/conda.exe" + assert conda_exe.exists() + return platform, tmp_env + + +def test_cross_build_example_from_env_yaml(tmp_path, request, platform_conda_exe): + platform, conda_exe = platform_conda_exe + input_path = _example_path("from_env_yaml") + + for installer, install_dir in create_installer( + input_path, + tmp_path, + timeout=600, + conda_exe=conda_exe, + extra_constructor_args=["--platform", platform] + ): + assert installer.exists() + + @pytest.mark.skipif(context.subdir != "linux-64", reason="Linux x64 only") def test_example_from_explicit(tmp_path, request): input_path = _example_path("from_explicit")