INNER CODE UNIT · Python
bootstrap_micromamba
PKU-EMBL/BASALT · BASALT_setup_China_mainland.py:174
def bootstrap_micromamba(destination: Path, url_template: str) -> Path:
"""Download the official self-contained micromamba binary safely."""
artifact = micromamba_platform()
url = url_template.format(platform=artifact)
destination = destination.expanduser().resolve()
destination.parent.mkdir(parents=True, exist_ok=True)
print("Downloading micromamba from: {}".format(url))
request = Request(url, headers={"User-Agent": "BASALT-installer/1.2"})
with tempfile.TemporaryDirectory(prefix="basalt-micromamba-") as temp_name:
archive = Path(temp_name) / "micromamba.tar.bz2"
try:
with urlopen(request, timeout=120) as response, archive.open("wb") as output:
shutil.copyfileobj(response, output)
except (HTTPError, URLError, TimeoutError, OSError) as exc:
raise InstallationError(
"Could not download micromamba from {}: {}".format(url, exc)
) from exc