Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

also catch OSError when detecting conda_exe for cross-platform builds #916

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion constructor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 36 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading