INNER CODE UNIT · Python
environment_exists
PKU-EMBL/BASALT · BASALT_setup_China_mainland.py:378
def environment_exists(
executable: str,
env_name: str,
environment: Dict[str, str],
dry_run: bool,
) -> bool:
"""Check for a named environment through the selected manager."""
if dry_run:
return False
try:
result = run_command(
[executable, "env", "list", "--json"],
env=environment,
capture=True,
)
paths = json.loads(result.stdout).get("envs", [])
except (InstallationError, ValueError, TypeError):
return False