MCPcopy Create free account
hub / github.com/conda/constructor / identify_conda_exe

Function identify_conda_exe

constructor/utils.py:325–343  ·  view source on GitHub ↗
(conda_exe: str | Path | None = None)

Source from the content-addressed store, hash-verified

323
324
325def identify_conda_exe(conda_exe: str | Path | None = None) -> tuple[StandaloneExe, str]:
326 if conda_exe is None:
327 conda_exe = normalize_path(join(sys.prefix, "standalone_conda", "conda.exe"))
328 if isinstance(conda_exe, Path):
329 conda_exe = str(conda_exe)
330 try:
331 output_version = check_output([conda_exe, "--version"], text=True)
332 output_version = output_version.strip()
333 fields = output_version.split()
334 if "conda" in fields:
335 return StandaloneExe.CONDA, fields[1]
336 # micromamba only returns the version number
337 output_help = check_output([conda_exe, "--help"], text=True)
338 if "mamba" in output_help:
339 return StandaloneExe.MAMBA, output_version
340 except (CalledProcessError, OSError) as exc:
341 logger.debug("Exception while identifying binary", exc_info=exc)
342 logger.warning("Could not identify standalone binary: %s", exc)
343 return None, None
344
345
346def format_conda_exe_name(conda_exe: str | Path) -> str:

Callers 4

test_examples.pyFile · 0.90
_is_micromambaFunction · 0.90
format_conda_exe_nameFunction · 0.85
main_buildFunction · 0.85

Calls 1

normalize_pathFunction · 0.85

Tested by 1

_is_micromambaFunction · 0.72