Skip to content

Commit

Permalink
Add a tool for configuring a new platform
Browse files Browse the repository at this point in the history
  • Loading branch information
psakievich committed Feb 13, 2024
1 parent 8f08ca9 commit f883e77
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions scripts/platform_configure_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /usr/bin/env spack-python
import argparse
import os
import pathlib

import spack.main
import spack.util.spack_yaml as syaml

from spack.util.module_cmd import module

parser = argparse.ArgumentParser()
parser.add_argument("input", help="input file describing what to configure")
parser.add_argument("--output", help="location where the configs should get written")

args = parser.parse_args()

input_path = pathlib.PurePath(args.input)
output_path = pathlib.PurePath(args.output)

os.environ["SPACK_USER_CONFIG_PATH"] = str(output_path)
exe_env = os.environ.copy()

with open(input_path, "r") as f:
manifest = syaml.load(f)

compiler = spack.main.SpackCommand("compiler", subprocess=True)
external_cmd = spack.main.SpackCommand("external", subprocess=True)

if "compilers" in manifest:
for c in manifest["compilers"]:
module("load", c)
print(compiler("find", "--scope=user", env=exe_env))
module("unload", c)

if "externals" in manifest:
print(external_cmd("find", *manifest["externals"], env=exe_env))

if "modules" in manifest:
for entry in manifest["modules"]:
m = entry["module"]
p = entry["packages"]
module("load", m)
print(external_cmd("find", *p, env=exe_env))
module("unload", m)

0 comments on commit f883e77

Please sign in to comment.