-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tool for configuring a new platform
- Loading branch information
1 parent
8f08ca9
commit f883e77
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |