Skip to content

Commit eb22d5c

Browse files
committed
Added a spack uberenv based build system.
1 parent 6319ae7 commit eb22d5c

File tree

10 files changed

+1207
-0
lines changed

10 files changed

+1207
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
*.*~*
44
.vscode
55
docs/doxygen/LvArrayConfig.hpp
6+
uberenv_libs
7+
spack-*.txt

scripts/uberenv/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# uberenv
2+
Automates using Spack (https://www.spack.io/) to build and deploy software.
3+
4+
Uberenv is a short python script that helps automate using Spack to build
5+
third-party dependencies for development and to deploy Spack packages.
6+
7+
Uberenv was released as part of the Conduit (https://github.com/LLNL/conduit/). It is included in-source in several projects, this repo is used to hold the latest reference version.
8+
9+
For more details, see Uberenv's documention:
10+
11+
https://uberenv.readthedocs.io
12+
13+
You can also find details about how it is used in Conduit's documentation:
14+
15+
https://llnl-conduit.readthedocs.io/en/latest/building.html#building-conduit-and-third-party-dependencies
16+
17+
Conduit's source repo also serves as an example for uberenv and spack configuration files, etc:
18+
19+
https://github.com/LLNL/conduit/tree/master/scripts/uberenv
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
###############################################################################
2+
# Copyright (c) 2015-2019, Lawrence Livermore National Security, LLC.
3+
#
4+
# Produced at the Lawrence Livermore National Laboratory
5+
#
6+
# LLNL-CODE-716457
7+
#
8+
# All rights reserved.
9+
#
10+
# This file is part of Ascent.
11+
#
12+
# For details, see: http://ascent.readthedocs.io/.
13+
#
14+
# Please also read ascent/LICENSE
15+
#
16+
# Redistribution and use in source and binary forms, with or without
17+
# modification, are permitted provided that the following conditions are met:
18+
#
19+
# * Redistributions of source code must retain the above copyright notice,
20+
# this list of conditions and the disclaimer below.
21+
#
22+
# * Redistributions in binary form must reproduce the above copyright notice,
23+
# this list of conditions and the disclaimer (as noted below) in the
24+
# documentation and/or other materials provided with the distribution.
25+
#
26+
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
27+
# be used to endorse or promote products derived from this software without
28+
# specific prior written permission.
29+
#
30+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33+
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
34+
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
35+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41+
# POSSIBILITY OF SUCH DAMAGE.
42+
#
43+
###############################################################################
44+
import os
45+
import sys
46+
import subprocess
47+
48+
from os.path import join as pjoin
49+
50+
# if you have bad luck with spack load, this
51+
# script is for you!
52+
#
53+
# Looks for subdir: spack or uberenv_libs/spack
54+
# queries spack for given package names and
55+
# creates a bash script that adds those to your path
56+
#
57+
#
58+
# usage:
59+
# python gen_spack_env_script.py [spack_pkg_1 spack_pkg_2 ...]
60+
#
61+
62+
def sexe(cmd,ret_output=False,echo = True):
63+
""" Helper for executing shell commands. """
64+
if echo:
65+
print("[exe: {}]".format(cmd))
66+
if ret_output:
67+
p = subprocess.Popen(cmd,
68+
shell=True,
69+
stdout=subprocess.PIPE,
70+
stderr=subprocess.STDOUT)
71+
res = p.communicate()[0]
72+
res = res.decode('utf8')
73+
return p.returncode,res
74+
else:
75+
return subprocess.call(cmd,shell=True)
76+
77+
78+
def spack_exe(spath=None):
79+
if spath is None:
80+
to_try = [pjoin("uberenv_libs","spack"), "spack"]
81+
for p in to_try:
82+
abs_p = os.path.abspath(p)
83+
print("[looking for spack directory at: {}]".format(abs_p))
84+
if os.path.isdir(abs_p):
85+
print("[FOUND spack directory at: {}]".format(abs_p))
86+
return os.path.abspath(pjoin(abs_p,"bin","spack"))
87+
print("[ERROR: failed to find spack directory!]")
88+
sys.exit(-1)
89+
else:
90+
spack_exe = os.path.abspath(spath,"bin","spack")
91+
if not os.path.isfile(spack_exec):
92+
print("[ERROR: failed to find spack directory at spath={}]").format(spath)
93+
sys.exit(-1)
94+
return spack_exe
95+
96+
def find_pkg(pkg_name):
97+
r,rout = sexe(spack_exe() + " find -p " + pkg_name,ret_output = True)
98+
print(rout)
99+
for l in rout.split("\n"):
100+
print(l)
101+
lstrip = l.strip()
102+
if not lstrip == "" and \
103+
not lstrip.startswith("==>") and \
104+
not lstrip.startswith("--"):
105+
return {"name": pkg_name, "path": l.split()[-1]}
106+
print("[ERROR: failed to find package named '{}']".format(pkg_name))
107+
sys.exit(-1)
108+
109+
def path_cmd(pkg):
110+
return('export PATH={}:$PATH\n'.format((pjoin(pkg["path"],"bin"))))
111+
112+
def write_env_script(pkgs):
113+
ofile = open("s_env.sh","w")
114+
for p in pkgs:
115+
print("[found {} at {}]".format(p["name"],p["path"]))
116+
ofile.write("# {}\n".format(p["name"]))
117+
ofile.write(path_cmd(p))
118+
print("[created {}]".format(os.path.abspath("s_env.sh")))
119+
120+
def main():
121+
pkgs = [find_pkg(pkg) for pkg in sys.argv[1:]]
122+
if len(pkgs) > 0:
123+
write_env_script(pkgs)
124+
else:
125+
print("usage: python gen_spack_env_script.py spack_pkg_1 spack_pkg_2 ...")
126+
127+
if __name__ == "__main__":
128+
main()

scripts/uberenv/project.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"package_name" : "lvarray",
3+
"package_version" : "develop",
4+
"package_final_phase" : "hostconfig",
5+
"package_source_dir" : "../..",
6+
"spack_url": "https://github.com/corbett5/spack",
7+
"spack_branch": "feature/corbett/lvarray",
8+
"spack_activate" : {},
9+
"spack_clean_packages": ["lvarray"],
10+
"build_jobs": 100
11+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
compilers:
2+
- compiler:
3+
4+
paths:
5+
cc: /usr/tce/packages/clang/clang-upstream-2019.08.15/bin/clang
6+
cxx: /usr/tce/packages/clang/clang-upstream-2019.08.15/bin/clang++
7+
f77:
8+
fc:
9+
flags:
10+
cflags: -mcpu=native -mtune=native
11+
cxxflags: -mcpu=native -mtune=native
12+
operating_system: rhel7
13+
target: ppc64le
14+
modules: []
15+
environment: {}
16+
extra_rpaths: []
17+
- compiler:
18+
19+
paths:
20+
cc: /usr/tce/packages/clang/clang-ibm-10.0.1-gcc-8.3.1/bin/clang
21+
cxx: /usr/tce/packages/clang/clang-ibm-10.0.1-gcc-8.3.1/bin/clang++
22+
f77:
23+
fc:
24+
flags:
25+
cflags: -mcpu=native -mtune=native
26+
cxxflags: -mcpu=native -mtune=native
27+
operating_system: rhel7
28+
target: ppc64le
29+
modules: []
30+
environment: {}
31+
extra_rpaths: []
32+
- compiler:
33+
34+
paths:
35+
cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc
36+
cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++
37+
f77:
38+
fc:
39+
flags:
40+
cflags: -mcpu=native -mtune=native
41+
cxxflags: -mcpu=native -mtune=native
42+
operating_system: rhel7
43+
target: ppc64le
44+
modules: []
45+
environment: {}
46+
extra_rpaths: []
47+
- compiler:
48+
49+
paths:
50+
cc: /usr/tce/packages/xl/xl-2020.09.17-cuda-11.0.2/bin/xlc
51+
cxx: /usr/tce/packages/xl/xl-2020.09.17-cuda-11.0.2/bin/xlC
52+
f77:
53+
fc:
54+
flags:
55+
cflags: -qarch=pwr9 -qtune=pwr9 -qxlcompatmacros -qalias=noansi -qsmp=omp -qhot -qnoeh -qsuppress=1500-029 -qsuppress=1500-036
56+
cxxflags: -qarch=pwr9 -qtune=pwr9 -qxlcompatmacros -qlanglvl=extended0x -qalias=noansi -qsmp=omp -qhot -qnoeh -qsuppress=1500-029 -qsuppress=1500-036
57+
operating_system: rhel7
58+
target: ppc64le
59+
modules: []
60+
environment: {}
61+
extra_rpaths: []
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
packages:
2+
all:
3+
target: [default]
4+
compiler: [gcc, clang, xl]
5+
6+
cuda:
7+
buildable: False
8+
externals:
9+
10+
modules:
11+
- cuda/10.1.243
12+
13+
modules:
14+
- cuda/11.0.2
15+
16+
cmake:
17+
buildable: False
18+
externals:
19+
20+
prefix: /usr/tce/packages/cmake/cmake-3.14.5
21+
22+
python:
23+
buildable: False
24+
externals:
25+
26+
prefix: /usr/tce/packages/python/python-3.8.2
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -------------------------------------------------------------------------
2+
# This is the default spack configuration file.
3+
#
4+
# Settings here are versioned with Spack and are intended to provide
5+
# sensible defaults out of the box. Spack maintainers should edit this
6+
# file to keep it current.
7+
#
8+
# Users can override these settings by editing the following files.
9+
#
10+
# Per-spack-instance settings (overrides defaults):
11+
# $SPACK_ROOT/etc/spack/config.yaml
12+
# Per-user settings (overrides default and site settings):
13+
# ~/.spack/config.yaml
14+
#
15+
# See https://spack.readthedocs.io/en/latest/config_yaml.html
16+
# -------------------------------------------------------------------------
17+
config:
18+
# This is the path to the root of the Spack install tree.
19+
# You can use $spack here to refer to the root of the spack instance.
20+
install_tree: $spack/..
21+
22+
# Locations where templates should be found
23+
template_dirs:
24+
- $spack/templates
25+
26+
# install directory layout
27+
install_path_scheme: "${ARCHITECTURE}-${COMPILERNAME}@${COMPILERVER}/${PACKAGE}@${VERSION}"
28+
29+
# Locations where different types of modules should be installed.
30+
module_roots:
31+
tcl: $spack/share/spack/modules
32+
lmod: $spack/share/spack/lmod
33+
34+
35+
# Temporary locations Spack can try to use for builds.
36+
#
37+
# Spack will use the first one it finds that exists and is writable.
38+
# You can use $tempdir to refer to the system default temp directory
39+
# (as returned by tempfile.gettempdir()).
40+
#
41+
# A value of $spack/var/spack/stage indicates that Spack should run
42+
# builds directly inside its install directory without staging them in
43+
# temporary space.
44+
#
45+
# The build stage can be purged with `spack purge --stage`.
46+
build_stage:
47+
- $spack/../builds
48+
49+
50+
# Cache directory already downloaded source tarballs and archived
51+
# repositories. This can be purged with `spack purge --downloads`.
52+
source_cache: $spack/var/spack/cache
53+
54+
55+
# Cache directory for miscellaneous files, like the package index.
56+
# This can be purged with `spack purge --misc-cache`
57+
misc_cache: .spack/misccache
58+
59+
60+
# If this is false, tools like curl that use SSL will not verify
61+
# certifiates. (e.g., curl will use use the -k option)
62+
verify_ssl: true
63+
64+
65+
# If set to true, Spack will always check checksums after downloading
66+
# archives. If false, Spack skips the checksum step.
67+
checksum: true
68+
69+
70+
# If set to true, `spack install` and friends will NOT clean
71+
# potentially harmful variables from the build environment. Use wisely.
72+
dirty: false
73+
74+
75+
# The default number of jobs to use when running `make` in parallel.
76+
# Spack will use up to this many jobs but limits it to the physical core count.
77+
# The default value is 16.
78+
build_jobs: 1000
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
compilers:
2+
- compiler:
3+
4+
paths:
5+
cc: /usr/tce/packages/clang/clang-10.0.1/bin/clang
6+
cxx: /usr/tce/packages/clang/clang-10.0.1/bin/clang++
7+
f77:
8+
fc:
9+
flags:
10+
cflags: -march=native -mtune=native
11+
cxxflags: -march=native -mtune=native
12+
operating_system: rhel7
13+
target: x86_64
14+
modules: []
15+
environment: {}
16+
extra_rpaths: []
17+
- compiler:
18+
19+
paths:
20+
cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc
21+
cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++
22+
f77:
23+
fc:
24+
flags:
25+
cflags: -march=native -mtune=native
26+
cxxflags: -march=native -mtune=native
27+
operating_system: rhel7
28+
target: x86_64
29+
modules: []
30+
environment: {}
31+
extra_rpaths: []
32+
- compiler:
33+
34+
paths:
35+
cc: /usr/tce/packages/intel/intel-19.1.2/bin/icc
36+
cxx: /usr/tce/packages/intel/intel-19.1.2/bin/icpc
37+
f77:
38+
fc:
39+
flags:
40+
cflags: -gcc-name=/usr/tce/packages/gcc/gcc-8.3.1/bin/gcc -march=native -mtune=native
41+
cxxflags: -gxx-name=/usr/tce/packages/gcc/gcc-8.3.1/bin/g++ -march=native -mtune=native
42+
operating_system: rhel7
43+
target: x86_64
44+
modules: []
45+
environment: {}
46+
extra_rpaths: []

0 commit comments

Comments
 (0)