from __future__ import annotations
import os
from pathlib import Path
def process_executables_root() -> Path:
configured = os.getenv("BIO_TOOLS_EXECUTABLE_ROOT") or os.getenv("BIO_WEB_EXECUTABLE_ROOT")
if configured:
return Path(configured).expanduser()
return Path.cwd() / "process_executables"
def environment_root() -> Path:
return process_executables_root() / "python_envs"
BIO_TOOLS_ENVIRONMENT_NAMES = {
"boltz": "boltz2",
"esmfold": "esmfold2",
"abmpnn": "proteinmpnn",
"proteinmpnn_ddg": "proteinmpnn-ddg",
"boltz_adme": "boltz-adme",
"tlimmuno": "tlimmuno2",
"antibody_annotator": "anarcii",
}
def environment_path(name: str) -> Path:
return environment_root() / BIO_TOOLS_ENVIRONMENT_NAMES.get(name, name)
def _binary_directory(name: str) -> Path:
return environment_path(name) / ("Scripts" if os.name == "nt" else "bin")
def environment_python(name: str) -> Path:
return _binary_directory(name) / ("python.exe" if os.name == "nt" else "python")
def environment_script(name: str, script: str) -> Path:
directory = _binary_directory(name)
if os.name != "nt":
return directory / script
for suffix in (".exe", ".cmd", ".bat"):
candidate = directory / f"{script}{suffix}"
if candidate.is_file():
return candidate
return directory / f"{script}.exe"