-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_start.sh
More file actions
executable file
·182 lines (149 loc) · 5.93 KB
/
quick_start.sh
File metadata and controls
executable file
·182 lines (149 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
# Spood Quick Start Demo - Approach #1 (Externals + Dependencies)
# Creates a demo Spack installation with EESSI externals
usage() {
cat << EOF
Usage: $(basename "$0") [OPTIONS] [DEMO_DIR]
Spood Quick Start Demo - Creates a demo Spack installation with EESSI externals
Prerequisites:
- EESSI environment must be initialized (EESSI_EPREFIX defined)
- Spack must be installed and available in PATH
Arguments:
DEMO_DIR Directory for demo installation (default: demo_spood)
Options:
-h, --help Show this help message and exit
Examples:
$(basename "$0")
$(basename "$0") ./demo
$(basename "$0") --help
EOF
}
set -e
# Parse command line arguments
HELP=false
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage
shift
;;
*)
DEMO_DIR="$1"
shift
;;
esac
done
# Set default demo directory if not provided
export DEMO_DIR=$(realpath "${DEMO_DIR:-demo_spood}")
# Create demo directory if it doesn't exist
mkdir -p "$DEMO_DIR"
# Check that EESSI_EPREFIX is defined
if [[ -z "${EESSI_EPREFIX}" ]]; then
echo "Error: EESSI_EPREFIX environment variable is not set. Have you initialized EESSI?"
exit 1
fi
# Check that spack is available
if ! command -v spack &> /dev/null; then
echo "Error: spack command not found. Please ensure Spack is installed and available in your PATH."
exit 1
elif ! spack --version &> /dev/null; then
echo "Error: spack command is not functioning properly. Please check your Spack installation."
# exit 1
fi
SPOOD_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SHARE_DIR="${SPOOD_ROOT}/share/spack_config"
EXAMPLES_DIR="${SPOOD_ROOT}/examples/ext_install"
EESSI_COMPAT_PKGS_PATHS=(
"${EESSI_EPREFIX}"
"${EESSI_EPREFIX}/usr"
)
echo -e "\033[1;38m============ Spood Demo Setup ============\033[0m"
echo -e "\033[1;38m • Demo directory:\033[0m"
echo " $DEMO_DIR"
# Configuring Spack environment variables
echo -e "\033[1;38m • Configuring Spack environment variables...\033[0m"
export SPACK_USER_CONFIG_PATH=$DEMO_DIR
export SPACK_USER_CACHE_PATH=$DEMO_DIR/cache
export SPOOD_DEBUG=0
echo " - SPACK_USER_CONFIG_PATH=$SPACK_USER_CONFIG_PATH"
echo " - SPACK_USER_CACHE_PATH=$SPACK_USER_CACHE_PATH"
# Create demo directory structure
mkdir -p "$DEMO_DIR"
mkdir -p "$DEMO_DIR/cache"
mkdir -p "$DEMO_DIR/opt"
cd $DEMO_DIR
# Copy/generate configuration files using pre-defined SPACK_USER_CONFIG_PATH
echo -e "\033[1;38m • Copying/generating Spack configuration files...\033[0m"
cp $SHARE_DIR/concretizer.yaml $SPACK_USER_CONFIG_PATH/concretizer.yaml
echo " - $SHARE_DIR/concretizer.yaml --> $SPACK_USER_CONFIG_PATH/concretizer.yaml"
export INSTALL_BASE_PATH=$DEMO_DIR
envsubst < $SHARE_DIR/config.yaml.tpl > $SPACK_USER_CONFIG_PATH/config.yaml
echo " - $SHARE_DIR/config.yaml.tpl --> $SPACK_USER_CONFIG_PATH/config.yaml"
envsubst < $SHARE_DIR/modules.yaml.tpl > $SPACK_USER_CONFIG_PATH/modules.yaml
echo " - $SHARE_DIR/modules.yaml.tpl --> $SPACK_USER_CONFIG_PATH/modules.yaml"
# envsubst < $SHARE_DIR/upstreams.yaml.tpl > $SPACK_USER_CONFIG_PATH/upstreams.yaml
# echo " - $SHARE_DIR/upstreams.yaml.tpl --> $SPACK_USER_CONFIG_PATH/upstreams.yaml"
# Copy and rename externals to packages.yaml
echo -e "\033[1;38m • Creating packages.yaml from externals_nocompat.yaml...\033[0m"
cp $EXAMPLES_DIR/externals_nocompat.yaml $SPACK_USER_CONFIG_PATH/packages.yaml
echo " - $EXAMPLES_DIR/externals_nocompat.yaml --> $SPACK_USER_CONFIG_PATH/packages.yaml"
# Replace the architecture with what EESSI sees and the target with what Spack expects
echo -e "\033[1;38m • Updating packages.yaml for local host...\033[0m"
echo " - Using EESSI installations for architecture ${EESSI_SOFTWARE_SUBDIR}"
echo " (based on EESSI architecture detection for host)"
sed -i s#x86_64/intel/haswell#${EESSI_SOFTWARE_SUBDIR}#g $SPACK_USER_CONFIG_PATH/packages.yaml
echo " - Telling Spack that these installations correspond to target $(spack arch -t)"
echo " (based on Spack architecture detection for host)"
sed -i s#target=haswell#target=$(spack arch -t)#g $SPACK_USER_CONFIG_PATH/packages.yaml
# Bootstrap Spack
echo -e "\033[1;38m • Bootstrapping Spack...\033[0m"
spack bootstrap now > /dev/null 2>&1
# Detect EESSI compat layer packages
echo -e "\033[1;38m • Detecting EESSI compat layer packages...\033[0m"
for path in "${EESSI_COMPAT_PKGS_PATHS[@]}"; do
echo " $ spack external find --all -p $path --exclude gcc"
spack external find --all -p "$path" --exclude gcc
done
echo
echo -e "\033[1;38m============ Setup Complete ============\033[0m"
echo
cat << EOF
To use this demo Spack installation, run:
export SPACK_USER_CONFIG_PATH=$DEMO_DIR
export SPACK_USER_CACHE_PATH=$DEMO_DIR/cache
Spack config directory: $DEMO_DIR"
Spack install directory: $DEMO_DIR/opt"
Spack modules directory: $DEMO_DIR/modules"
EOF
echo -e "\033[1;38m============ Demo Commands ============\033[0m"
# 1. Show configured externals
echo -e "\033[1;38m 1. List configured external packages:\033[0m"
echo " $ spack find -p --show-configured-externals"
echo
spack find -p --show-configured-externals
# 2. Show available compilers
echo
echo -e "\033[1;38m 2. Check available compilers:\033[0m"
echo " $ spack compiler list"
echo
spack compiler list
# 3. Try a sample spec
echo
echo -e "\033[1;38m 3. Concretize a sample spec (reusing externals):\033[0m"
echo " $ spack spec -Ilt quantum-espresso~mpi"
echo
spack spec -Ilt "quantum-espresso~mpi"
# 4. Install a sample spec
echo
echo -e "\033[1;38m 4. Install a sample spec (if desired):\033[0m"
echo " $ spack install quantum-espresso~mpi"
echo
spack install "quantum-espresso~mpi"
# 5. Verify the installation
echo
echo -e "\033[1;38m 5. Verify the installation:\033[0m"
echo " $ ldd $(spack location -i quantum-espresso)/bin/pw.x"
echo
ldd $(spack location -i quantum-espresso)/bin/pw.x
echo
echo -e "\033[1;38m============ End of Demo ============\033[0m"