Newer
Older
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]
logging.debug(f"{toolchain_map=}")
# pretty print the toolchain map key as the heading
# and the value as the list of toolchains
for microarch, toolchains in toolchain_map.items():
plog.info(f"- {microarch}")
for toolchain in toolchains:
plog.info(f" [module use {str(release_base_dir / microarch / 'lmod/Core')}]")
plog.info("")
parser = argparse.ArgumentParser(description=about_tool)
parser.add_argument(
"--log",
"-l",
dest="loglevel",
choices=["warning", "info", "debug"],
required=False,
default="warning",
help="Set the log level",
)
parser.add_argument("--version", action="version", version=__version__)
subparsers = parser.add_subparsers(
dest="action", title="actions", description="valid actions", required=True
)
subparsers.required = True
list_of_cmds = [
("available", "Show software available for installation"),
("install", "Install a software environment"),
# ("reinstall", "Reinstall a software environment"),
# ("remove", "Remove a software environment or toolchains from an environment"),
# ("start-new", "Start a new software environment version"),
("status", "Show status: what is installed?"),
("prepare", "Prepare installation of MPSD-release (dev only)"),
]
for cmd, help_text in list_of_cmds:
subp = subparsers.add_parser(cmd, help=help_text)
if cmd == "start-new":
subp.add_argument(
"--from-release",
dest="from_release",
type=str,
required=True,
help="Release version to start from",
)
subp.add_argument(
"--to-release",
dest="to_release",
type=str,
required=True,
help="Release version to create",
)
"release",
type=str,
help="Release version to prepare, install, reinstall or remove",
if cmd in ["install", "reinstall", "remove"]:
tool_chain_help = (
f"Pass a list of toolchains to command {cmd}. "
"Use '--toolchains ALL' to "
f"{cmd} all toolchains. If '--toolchain' is not "
"specified, list available toolchains for the release "
"(after environment has been prepared if not done yet)."
)
"--toolchains", # first option defines attribute
# name `args.toolchains` in `args = parser_args()`
"--toolchain", # allow singular as alternative
# (-> creates attribute `args.toolchains` if used)
dest="toolchains",
default="NONE",
help=tool_chain_help,
)
subp.add_argument(
"--enable-build-cache",
action="store_true",
"Enable Spack build cache. Useful for reinstallation but "
"consumes time and disk space."
# Carry out the action
args = parser.parse_args()
# target dir is the place where this script exists. the
root_dir = Path(os.path.dirname(os.path.realpath(__file__)))
get_installer_log_file_path(args.release, args.action, root_dir),
remove_environment(args.release, args.toolchains, root_dir)
elif args.action == "start-new":
start_new_environment(args.from_release, args.to_release, root_dir)
args.release, args.toolchains, root_dir, args.enable_build_cache
prepare_environment(args.release, root_dir)
get_available_toolchains(args.release)
message = (
f"No known action found ({args.action=}). Should probably never happen."
)
logging.error(message)
raise NotImplementedError(message)