-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwraprun_formula.rb
219 lines (179 loc) · 6.57 KB
/
wraprun_formula.rb
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
class WraprunFormula < Formula
homepage "https://github.com/olcf/wraprun"
url "https://github.com/olcf/wraprun/archive/v0.2.4.tar.gz"
supported_build_names /python2.7/, /python3/
depends_on do
[python_module_from_build_name, "python_yaml"]
end
concern for_version("dev") do
included do
url "none"
module_commands do
pe = "PE-"
pe = "PrgEnv-" if cray_system?
commands = [ "unload #{pe}gnu #{pe}pgi #{pe}cray #{pe}intel python" ]
commands << "load #{pe}gnu" if build_name =~ /gnu/
commands << "swap gcc gcc/#{$1}" if build_name =~ /gnu([\d\.]+)/
commands << "load #{pe}pgi" if build_name =~ /pgi/
commands << "swap pgi pgi/#{$1}" if build_name =~ /pgi([\d\.]+)/
commands << "load #{pe}intel" if build_name =~ /intel/
commands << "swap intel intel/#{$1}" if build_name =~ /intel([\d\.]+)/
commands << "load #{pe}cray" if build_name =~ /cray/
commands << "swap intel cray/#{$1}" if build_name =~ /cray([\d\.]+)/
commands << "load #{python_module_from_build_name}"
commands << "load python_setuptools"
commands << "load python_yaml"
commands << "load dynamic-link"
commands << "load cmake3"
commands << "load git"
commands
end
def install
module_list
Dir.chdir "#{prefix}"
system "rm -rf source"
system "git clone https://github.com/olcf/wraprun.git source" unless Dir.exists?("source")
Dir.chdir "#{prefix}/source"
system "git checkout origin/development"
# normal build from here:
system "rm -rf build; mkdir build"
Dir.chdir "build"
system "cmake -DCMAKE_INSTALL_PREFIX=#{prefix} .."
system "make"
system "make install"
Dir.chdir "#{prefix}/source/python"
system_python "setup.py install --root=#{prefix} --prefix=''"
end
end
end
module_commands do
pe = "PE-"
pe = "PrgEnv-" if cray_system?
commands = [ "unload #{pe}gnu #{pe}pgi #{pe}cray #{pe}intel python" ]
commands << "load #{pe}gnu" if build_name =~ /gnu/
commands << "swap gcc gcc/#{$1}" if build_name =~ /gnu([\d\.]+)/
commands << "load #{pe}pgi" if build_name =~ /pgi/
commands << "swap pgi pgi/#{$1}" if build_name =~ /pgi([\d\.]+)/
commands << "load #{pe}intel" if build_name =~ /intel/
commands << "swap intel intel/#{$1}" if build_name =~ /intel([\d\.]+)/
commands << "load #{pe}cray" if build_name =~ /cray/
commands << "swap intel cray/#{$1}" if build_name =~ /cray([\d\.]+)/
commands << "load #{python_module_from_build_name}"
commands << "load python_setuptools"
commands << "load python_yaml"
commands << "load dynamic-link"
commands << "load cmake3"
commands
end
def install
module_list
system "rm -rf build; mkdir build"
Dir.chdir "build"
system "cmake -DCMAKE_INSTALL_PREFIX=#{prefix} .."
system "make"
system "make install"
Dir.chdir "#{prefix}/source/python"
system_python "setup.py install --root=#{prefix} --prefix=''"
end
modulefile <<-MODULEFILE.strip_heredoc
#%Module
proc ModulesHelp { } {
puts stderr "<%= @package.name %> <%= @package.version %>"
puts stderr ""
}
# One line description
module-whatis "<%= @package.name %> <%= @package.version %>"
if { ! [ is-loaded python ] } {
puts stderr "WARNING: Wraprun requires python."
puts stderr "The default python module is being loaded by wraprun but it will not be removed when the wraprun module is unloaded."
puts stderr "Manually load any python module version prior to wraprun to supress this message."
puts stderr ""
module load python
}
prereq python
module load python_yaml
prereq python_yaml
module load dynamic-link
setenv W_UNSET_PRELOAD 1
setenv W_IGNORE_SEGV 1
setenv W_IGNORE_RETURN_CODE 1
setenv W_IGNORE_ABRT 1
setenv W_SIG_DFL 1
<%= pe_with_python_build_list @package, @builds %>
set PREFIX <%= @package.version_directory %>/$BUILD
prepend-path PATH $PREFIX/bin
prepend-path LD_LIBRARY_PATH $PREFIX/lib
prepend-path PYTHONPATH $PREFIX/lib/$LIBDIR/site-packages
prepend-path MANPATH $PREFIX/share/man/man1
# The libfmpich library is suffixed with the PE name, so we must extract it
set compiler $env(PE_ENV)
set compiler [string tolower $compiler]
set libmpichf $env(MPICH_DIR)/lib/libfmpich_$compiler.so
if { [file exists $libmpichf] == 0 } {
set libmpichf $env(MPICH_DIR)/lib/libfmpich.so
if { [file exists $libmpichf] == 0 } {
puts stderr "Module failed, libfmpich.so not found!"
exit [1]
}
}
setenv WRAPRUN_PRELOAD $libmpichf:$PREFIX/lib/libsplit.so
MODULEFILE
end
Smithy::ModuleFile.class_eval do
def pe_with_python_build_list(package, builds, args={})
output = ""
Smithy::ModuleFile::compilers.each_with_index do |e,i|
versions = Hash.new do |cvs,cv|
cvs[cv] = Hash.new do |pvs,pv|
pvs[pv] = Array.new
end
end
comp_builds = builds.select{|b| b =~ e[:build_name_regex]}
comp_builds.each do |b|
b =~ e[:build_name_regex]
cv = "#{$2}"
b =~ /(python)([0-9\.]*)/
pv = "#{$2}"
versions[cv][pv] << b if module_is_available?(get_python_version_from_build_name(b))
end
if i == 0
output << "if "
else
output << "} elseif "
end
output << "[ is-loaded #{e[:prg_env]} ] {\n"
versions.each_with_index do |(cv, ps), ci|
if ci == 0
output << " if "
else
output << " } elseif "
end
output << "[ is-loaded #{e[:compiler_name]}/#{cv} ] {\n"
ps.each_with_index do |(pv, bs), pi|
if pi == 0
output << " if "
else
output << " } elseif "
end
output << "[ is-loaded python/#{pv} ] {\n"
if bs.length > 1
output << " puts stderr \"Warning: possible wraprun modulefile name collision.\"\n"
output << " puts stderr \"Please notify the system administrator.\"\n"
end
bs.each_with_index do |b, bi|
output << " set LIBDIR #{python_libdir(get_python_version_from_build_name(b))}\n"
output << " set BUILD #{b}\n"
if ((bi == bs.size - 1) and (pi == ps.size - 1))
output << " }\n"
end
end
if pi == ps.size - 1
output << " }\n"
end
end
end
end
output << "}"
return output
end
end