INNER CODE UNIT · Python
render_environment
PKU-EMBL/BASALT · BASALT_setup_China_mainland.py:317
def render_environment(source: Path, destination: Path, channels: Sequence[str]) -> None:
"""Render a temporary environment file containing explicit channels."""
lines = source.read_text(encoding="utf-8").splitlines()
try:
channel_start = next(
index for index, line in enumerate(lines) if line.strip() == "channels:"
)
dependency_start = next(
index
for index, line in enumerate(lines[channel_start + 1 :], channel_start + 1)
if line.strip() == "dependencies:"
)
except StopIteration as exc:
raise InstallationError(
"Invalid basalt_environment.yml: channels/dependencies section missing."
) from exc
rendered = lines[:channel_start] + ["channels:"]