diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py index dc2acb1037d34158e58cf7654e5f3198f587f598..f112f6aff902a236f5b18211a689e21d59aa062f 100755 --- a/mpsd-software-environment.py +++ b/mpsd-software-environment.py @@ -12,6 +12,7 @@ import time from pathlib import Path from typing import List, Tuple, Union import re +import json # If 'rich' is available ("pip install rich" or "apt-get install python3-rich"), # then use coloured output, otherwise proceed as before @@ -834,16 +835,30 @@ def environment_status(mpsd_release, script_dir): # raise NotImplementedError(msg) release_base_dir = script_dir / mpsd_release os.environ.get("MPSD_OS", "UNKNOWN_OS") - microarch = get_native_microarchitecture() - toolchain_dir = release_base_dir / microarch + sys_microarch = get_native_microarchitecture() + toolchain_dir = release_base_dir / sys_microarch spack_dir = toolchain_dir / "spack" + lmod_toolchain_dir = release_base_dir / sys_microarch / "lmod" / "Core" / "toolchains" + if not spack_dir.exists(): raise ValueError( f"Release {mpsd_release} has not been completly installed yet" ", try reinstalling it (spack directory not found)" ) - with os_chdir(spack_dir): - pass + # find all folders for all microarch in the release directory except for the blacklisted folder + black_listed_microarchs = ["spack-environments", "logs"] + + list_of_microarchs = os.listdir(release_base_dir) + list_of_microarchs.remove(black_listed_microarchs) + toolchain_map = {} + for microarch in list_of_microarchs: + # get a list of all the toolchains in the microarch + possible_toolchains = (release_base_dir/microarch).glob("lmod/Core/toolchains/*.lua") + # append toolchain which is the name of the file without the .lua extension + toolchain_map[microarch] = [toolchain.stem for toolchain in possible_toolchains] + + # pretty print the toolchain map + print(json.dumps(toolchain_map, indent=4, sort_keys=True)) def main():