Skip to content

Instantly share code, notes, and snippets.

@tsibley
Created May 6, 2025 21:26
Show Gist options
  • Save tsibley/0a725572fdf6f5cb28add525dbfd5920 to your computer and use it in GitHub Desktop.
Save tsibley/0a725572fdf6f5cb28add525dbfd5920 to your computer and use it in GitHub Desktop.
import json
import os
from subprocess import run, PIPE, STDOUT
for prog in ["conda", "mamba", "micromamba"]:
for arch in [None, "x86_64", ""]:
env = {**os.environ}
if arch is None:
try:
del env["CONDA_OVERRIDE_ARCHSPEC"]
except KeyError:
pass
else:
env["CONDA_OVERRIDE_ARCHSPEC"] = arch
for line in run([prog, "info"], env = env, stdout = PIPE, stderr = STDOUT, text = True, check = True).stdout.splitlines():
if "__archspec" in line:
archspec = line.replace("virtual packages :", "").strip()
break
else:
archspec = None
version = run([prog, "--version"], stdout = PIPE, text = True, check = True).stdout.strip()
version = version.replace(f"{prog} ", "")
print(json.dumps({
"prog": f"{prog} ({version})",
"CONDA_OVERRIDE_ARCHSPEC": arch if arch is not None else "(not set)",
"__archspec": archspec if archspec is not None else "(not present)" }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment