Debian Codegraph @

cmake/tribits/devtools_install/install-openmpi.py

raw
1 #!/usr/bin/env python3
2
3 # @HEADER
4 # *****************************************************************************
5 # TriBITS: Tribal Build, Integrate, and Test System
6 #
7 # Copyright 2013-2016 NTESS and the TriBITS contributors.
8 # SPDX-License-Identifier: BSD-3-Clause
9 # *****************************************************************************
10 # @HEADER
11
12 #
13 # Version info that will change with new versions
14 #
15
16 openmpiVersion = "1.4.3"
17 openmpiTarball = "openmpi-"+openmpiVersion+".tar.gz"
18 openmpiSrcDir = "openmpi-"+openmpiVersion
19
20
21 #
22 # Script code
23 #
24
25
26 from InstallProgramDriver import *
27 from GeneralScriptSupport import *
28
29
30 class OpenMpiInstall:
31
32 def __init__(self):
33 self.dummy = None
34
35 def getProductName(self):
36 return "openmpi-"+openmpiVersion
37
38 def getScriptName(self):
39 return "install-openmpi.py"
40
41 def getExtraHelpStr(self):
42 return """
43 This script builds openmpi-"""+openmpiVersion+""" from source compiled with
44 the configured GCC compiler (see options --with-gcc --with-lib-dir).
45 """
46
47 def getBaseDirName(self):
48 return "openmpi.BASE"
49
50 def injectExtraCmndLineOptions(self, clp):
51 clp.add_option(
52 "--checkout-cmnd", dest="checkoutCmnd", type="string",
53 default="git clone software.sandia.gov:/space/git/TrilinosToolset/openmpi.BASE "+\
54 self.getBaseDirName(),
55 help="Command used to check out "+self.getProductName()+" and dependent source tarball(s)." )
56 clp.add_option(
57 "--extra-configure-options", dest="extraConfigureOptions", type="string", default="",
58 help="Extra options to add to the 'configure' command for "+self.getProductName()+"." \
59 +" Note: This does not override the hard-coded configure options." )
60 clp.add_option(
61 "--with-path", dest="withPath", type="string", default="",
62 help="Prepended path to find executables." )
63 clp.add_option(
64 "--with-lib-dir", dest="withLibDir", type="string", default="",
65 help="Libraries to add to LD_LIBRARY_PATH when configuring, building, and installing." )
66
67 def echoExtraCmndLineOptions(self, inOptions):
68 cmndLine = ""
69 cmndLine += " --checkout-cmnd='"+inOptions.checkoutCmnd+"' \\\n"
70 if inOptions.extraConfigureOptions:
71 cmndLine += " --extra-configure-options='"+inOptions.extraConfigureOptions+"' \\\n"
72 cmndLine += " --with-path='"+inOptions.withPath+"' \\\n"
73 cmndLine += " --with-lib-dir='"+inOptions.withLibDir+"' \\\n"
74 return cmndLine
75
76 def setup(self, inOptions):
77 self.inOptions = inOptions
78 self.baseDir = os.getcwd()
79 self.openmpiBaseDir = self.baseDir+"/"+self.getBaseDirName()
80 self.openmpiSrcBaseDir = self.openmpiBaseDir+"/"+openmpiSrcDir
81 self.openmpiBuildBaseDir = self.openmpiBaseDir+"/openmpi-build"
82 self.scriptBaseDir = getScriptBaseDir()
83
84 def doCheckout(self):
85 echoRunSysCmnd(self.inOptions.checkoutCmnd)
86
87 def doUntar(self):
88 echoChDir(self.openmpiBaseDir)
89 echoRunSysCmnd("tar -xzvf "+openmpiTarball)
90
91 def doConfigure(self):
92 createDir(self.openmpiBuildBaseDir, True, True)
93 echoRunSysCmnd(
94 self.getEnvCmnd()+"../"+openmpiSrcDir+"/configure "+\
95 " "+self.inOptions.extraConfigureOptions+\
96 " --prefix="+self.inOptions.installDir)
97
98 def doBuild(self):
99 echoChDir(self.openmpiBuildBaseDir)
100 echoRunSysCmnd(self.getEnvCmnd()+"make "+self.inOptions.makeOptions)
101
102 def doInstall(self):
103 echoChDir(self.openmpiBuildBaseDir)
104 echoRunSysCmnd(self.getEnvCmnd()+"make "+self.inOptions.makeOptions+" install")
105
106 def getFinalInstructions(self):
107 return """
108 To use the installed version of openmpi-"""+openmpiVersion+""" access the include
109 headers in the directory:
110
111 """+self.inOptions.installDir+"""/include
112
113 the libraries in the directory:
114
115 """+self.inOptions.installDir+"""/lib
116
117 and the executables and compiler wrappers (e.g. mpicc, mpic++, mpirun, etc.) in:
118
119 """+self.inOptions.installDir+"""/bin
120
121 Actually, using the MPI compiler wrappers mpicc, mpic++, etc. is preferred.
122 """
123
124 def getEnvCmnd(self):
125 envCmnd = "env "
126 if self.inOptions.withPath:
127 envCmnd = "PATH="+self.inOptions.withPath+":$PATH "
128 if self.inOptions.withLibDir:
129 envCmnd += "LD_LIBRARY_PATH="+self.inOptions.withLibDir+":$LD_LIBRARY_PATH "
130 envCmnd += "echo 'PATH='$PATH && echo 'LD_LIBRARY_PATH='$LD_LIBRARY_PATH && which gcc && gcc --version && "
131 return envCmnd
132
133
134 #
135 # Executable statements
136 #
137
138 openmpiInstaller = InstallProgramDriver(OpenMpiInstall())
139
140 openmpiInstaller.runDriver()