def main(cmndLineArgs): # # Get the command-line options # inOptions = getCmndLineOptions(cmndLineArgs) if inOptions.skipOp: print("\n***") print( "*** NOTE: --no-op provided, will only trace actions and not touch the filesystem!" ) print("***\n") commonToolsSelected = \ getToolsSelectedArray(inOptions.commonTools, commonToolsArray) print("\nSelected common tools = " + commonToolsSelected) commonToolsSelectedSet = set(commonToolsSelected) compilerToolsetSelected = \ getToolsSelectedArray(inOptions.compilerToolset, compilerToolsetArray) print("\nSelected compiler toolset = " + compilerToolsetSelected) compilerToolsetSelectedSet = set(compilerToolsetSelected) gccVersion = gcc_version_default #ToDo: Make variable! dev_env_base_dir = inOptions.installDir ### print("\n\nA) Setup the install directory <dev_env_base> ='" + dev_env_base_dir + "':\n") ### dev_env_base_exists = os.path.exists(dev_env_base_dir) common_tools_dir = os.path.join(dev_env_base_dir, "common_tools") common_tools_exists = os.path.exists(common_tools_dir) compiler_toolset_base_dir = os.path.join(dev_env_base_dir, "gcc-" + gccVersion) compiler_toolset_base_exists = os.path.exists(compiler_toolset_base_dir) compiler_toolset_dir = os.path.join(compiler_toolset_base_dir, "toolset") compiler_toolset_exists = os.path.exists(compiler_toolset_dir) if inOptions.doInitialSetup: if not dev_env_base_exists: print("Creating directory '" + dev_env_base_dir + "' ...") if not inOptions.skipOp: os.makedirs(dev_env_base_dir) if not common_tools_exists: print("Creating directory '" + common_tools_dir + "' ...") if not inOptions.skipOp: os.makedirs(common_tools_dir) # Always create this directory so we can write the load_dev_env.sh script! if not compiler_toolset_base_exists: print("Creating directory '" + compiler_toolset_base_dir + "' ...") if not inOptions.skipOp: os.makedirs(compiler_toolset_base_dir) if not compiler_toolset_exists: print("Creating directory '" + compiler_toolset_dir + "' ...") if not inOptions.skipOp: os.makedirs(compiler_toolset_dir) print("Writing new files " + inOptions.loadDevEnvFileBaseName + ".[sh,csh] ...") if not inOptions.skipOp: writeLoadDevEnvFiles(dev_env_base_dir, compiler_toolset_base_dir, inOptions) else: print("Skipping setup of the install directory by request!") assertInstallDirExists(dev_env_base_dir, inOptions) assertInstallDirExists(common_tools_dir, inOptions) assertInstallDirExists(compiler_toolset_base_dir, inOptions) assertInstallDirExists(compiler_toolset_dir, inOptions) ### print("\n\nB) Download all sources for each selected tool:\n") ### if inOptions.doDownload: if "cmake" in commonToolsSelectedSet: downloadToolSource("cmake", cmake_version_default, inOptions.sourceGitUrlBase, inOptions) if "autoconf" in commonToolsSelectedSet: downloadToolSource("autoconf", autoconf_version_default, inOptions.sourceGitUrlBase, inOptions) if "gcc" in compilerToolsetSelectedSet: downloadToolSource("gcc", gcc_version_default, inOptions.sourceGitUrlBase, inOptions) if "mpich" in compilerToolsetSelectedSet: downloadToolSource("mpich", mpich_version_default, inOptions.sourceGitUrlBase, inOptions) else: print("Skipping download of the source for the tools on request!") if inOptions.doInstall: print("NOTE: The downloads had better be there for the install!") ### print("\n\nC) Untar, configure, build and install each selected tool:\n") ### if inOptions.doInstall: if "gitdist" in commonToolsSelectedSet: print("\nInstalling gitdist ...") echoRunSysCmnd("cp " + pythonUtilsDir + "/gitdist " + common_tools_dir + "/") InstallProgramDriver.fixupInstallPermissions( inOptions, common_tools_dir) if "cmake" in commonToolsSelectedSet: installToolFromSource("cmake", cmake_version_default, common_tools_dir, None, inOptions) if "autoconf" in commonToolsSelectedSet: installToolFromSource("autoconf", autoconf_version_default, common_tools_dir, None, inOptions) if "gcc" in compilerToolsetSelectedSet: installToolFromSource("gcc", gcc_version_default, compiler_toolset_dir, None, inOptions) if "mpich" in compilerToolsetSelectedSet: gccInstallDir = compiler_toolset_dir + "/gcc-" + gcc_version_default if not os.path.exists(gccInstallDir) and not inOptions.skipOp: raise Exception("Error, gcc has not been installed yet." \ " Missing directory '"+gccInstallDir+"'") LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "") installToolFromSource( "mpich", mpich_version_default, compiler_toolset_dir, { "CC": gccInstallDir + "/bin/gcc", "CXX": gccInstallDir + "/bin/g++", "FC": gccInstallDir + "/bin/gfortran", "LD_LIBRARY_PATH": gccInstallDir + "/lib64:" + LD_LIBRARY_PATH }, inOptions) else: print("Skipping install of the tools on request!") ### print("\n\nD) Final instructions for using installed dev env:") ### if inOptions.showFinalInstructions: print("\nTo use the new dev env, just source the file:\n") print(" source " + compiler_toolset_base_dir + "/load_dev_env.sh\n") print("for sh or bash shells (or load_dev_env.csh for csh shell).\n") print("TIP: Add this source to your ~/.bash_profile!") else: print("Skipping on request ...") if inOptions.skipOp: print("\n***") print( "*** NOTE: --no-op provided, only traced actions that would have been taken!" ) print("***") print("\n[End]")
def main(cmndLineArgs): # # Get the command-line options # autoconf_version = autoconf_version_default cmake_version = cmake_version_default gcc_version = gcc_version_default mpich_version = mpich_version_default mvapich_version = mvapich_version_default mvapichInstalled = False #iterates over tools selected. If name is specified and a ':' is present, non-default version was specified. Updating install version to specified value #if no version was specified, default version will be installed inOptions = getCmndLineOptions(cmndLineArgs) versionList = dict() for toolName in inOptions.commonTools.split(','): if "cmake" in toolName and ':' in toolName: cmake_version = toolName.split(':')[1] elif "autoconf" in toolName and ':' in toolName: autoconf_version = toolName.split(':')[1] for toolName in inOptions.compilerToolset.split(','): if "gcc" in toolName and ':' in toolName: gcc_version = toolName.split(':')[1] elif "mpich" in toolName and ':' in toolName: mpich_version = toolName.split(':')[1] elif "mvapich" in toolName and ':' in toolName: mvapich_version = toolName.split(':')[1] mvapichInstalled = True versionList["cmake"] = cmake_version versionList["autoconf"] = autoconf_version versionList["gcc"] = gcc_version versionList["mpich"] = mpich_version versionList["mvapich"] = mvapich_version if inOptions.skipOp: print("\n***") print( "*** NOTE: --no-op provided, will only trace actions and not touch the filesystem!" ) print("***\n") commonToolsSelected = \ getToolsSelectedArray(inOptions.commonTools, commonToolsArray) print("\nSelected common tools = " + str(commonToolsSelected)) commonToolsSelectedSet = set(commonToolsSelected) compilerToolsetSelected = \ getToolsSelectedArray(inOptions.compilerToolset, compilerToolsetArray) print("\nSelected compiler toolset = " + str(compilerToolsetSelected)) compilerToolsetSelectedSet = set(compilerToolsetSelected) dev_env_base_dir = inOptions.installDir ### print("\n\nA) Setup the install directory <dev_env_base> ='" + dev_env_base_dir + "':\n") ### dev_env_base_exists = os.path.exists(dev_env_base_dir) common_tools_dir = os.path.join(dev_env_base_dir, "common_tools") common_tools_exists = os.path.exists(common_tools_dir) compiler_toolset_base_dir = os.path.join(dev_env_base_dir, "gcc-" + gcc_version) compiler_toolset_base_exists = os.path.exists(compiler_toolset_base_dir) compiler_toolset_dir = os.path.join(compiler_toolset_base_dir, "toolset") compiler_toolset_exists = os.path.exists(compiler_toolset_dir) dev_env_dir = os.path.join(dev_env_base_dir, "env") dev_env_exists = os.path.exists(dev_env_dir) if inOptions.doInitialSetup: if not dev_env_base_exists: print("Creating directory '" + dev_env_base_dir + "' ...") if not inOptions.skipOp: os.makedirs(dev_env_base_dir) if not dev_env_exists and not inOptions.skipOp: os.makedirs(dev_env_dir) if not common_tools_exists: print("Creating directory '" + common_tools_dir + "' ...") if not inOptions.skipOp: os.makedirs(common_tools_dir) # Always create this directory so we can write the load_dev_env.sh script! if not compiler_toolset_base_exists: print("Creating directory '" + compiler_toolset_base_dir + "' ...") if not inOptions.skipOp: os.makedirs(compiler_toolset_base_dir) if not compiler_toolset_exists: print("Creating directory '" + compiler_toolset_dir + "' ...") if not inOptions.skipOp: os.makedirs(compiler_toolset_dir) print("Writing new files " + inOptions.loadDevEnvFileBaseName + ".[sh,csh] ...") if not inOptions.skipOp: writeLoadDevEnvFiles(dev_env_base_dir, dev_env_dir, inOptions, versionList, mvapichInstalled) else: print("Skipping setup of the install directory by request!") assertInstallDirExists(dev_env_base_dir, inOptions) assertInstallDirExists(common_tools_dir, inOptions) assertInstallDirExists(compiler_toolset_base_dir, inOptions) assertInstallDirExists(compiler_toolset_dir, inOptions) if not inOptions.skipOp: os.system("mkdir " + dev_env_base_dir + "/images") os.system("mkdir " + dev_env_base_dir + "/images/dev_env") os.system("mkdir " + dev_env_base_dir + "/images/install") gcc_first = gcc_version[0] gcc_short = str() for chr in gcc_version: if chr != '.': gcc_short += chr if mvapichInstalled: mpi_version = "mvapich2-" + mvapich_version else: mpi_version = "mpich-" + mpich_version if inOptions.mkl_true: mkl_true = "true" tpl_url = 'https://github.com/ehcole/MPACT_tpls.git' tpl_source_dir = "/MPACT_tpls/TPL_build/" else: mkl_true = "false" tpl_url = "https://github.com/CASL/vera_tpls.git" tpl_source_dir = "/vera_tpls/TPL_build/" os.system("autoconf") os.system( "./configure GCC_VERSION=gcc_version GCC_FIRST=gcc_first GCC_SHORT=gcc_short MPI_VERSION=MPI_VERSION CMAKE_VERSION=cmake_version TPL_URL=tpl_url TPL_SOURCE_DIR=tpl_source_dir MKL_TRUE=mkl_true" ) os.system("mv Dockerfile " + dev_env_base_dir + "/images/dev_env") os.system("mv Dockerfile_install " + dev_env_base_dir + "/images/install") ### print("\n\nB) Download all sources for each selected tool:\n") ### if inOptions.doDownload: for tool in commonToolsSelectedSet: if "cmake" in tool: print("") print("Downloading the source for cmake-" + cmake_version + " ...") print("") cmakeShort = cmake_version[:-2] if not inOptions.skipOp: try: os.system("wget https://cmake.org/files/v" + cmakeShort + "/cmake-" + cmake_version + ".tar.gz") except: print( "Invalid CMake version passed. No Download link found." ) exit(1) os.system("mv cmake-" + cmake_version + ".tar.gz " + common_tools_dir) else: print("wget " + dev_env_base_dir + "/common_tools https://cmake.org/files/v" + cmakeShort + "/cmake-" + cmake_version + ".tar.gz") elif "autoconf" in tool: downloadToolSource("autoconf", autoconf_version, inOptions.sourceGitUrlBase, inOptions) for tool in compilerToolsetSelectedSet: if "gcc" in tool: print("") print("Downloading the source for gcc-" + gcc_version + " ...") print("") if not inOptions.skipOp: try: os.system("wget https://ftp.gnu.org/gnu/gcc/gcc-" + gcc_version + "/gcc-" + gcc_version + ".tar.gz") except: print( "Invalid gcc version passed. No Download link found." ) exit(1) else: print("wget https://ftp.gnu.org/gnu/gcc/gcc-" + gcc_version + "/gcc-" + gcc_version + ".tar.gz") elif "mpich" in tool: if mpich_version == '3.1.3': downloadToolSource("mpich", mpich_version, inOptions.sourceGitUrlBase, inOptions) else: print("") print("Downloading the source for mpich-" + mpich_version + " ..") print("") if not inOptions.skipOp: try: os.system( "wget / http://www.mpich.org/static/downloads/" + mpich_version + "/mpich-" + mpich_version + ".tar.gz") except: print( "Invalid mpich version passed. No Download link found." ) exit(1) else: print("wget http://www.mpich.org/static/downloads/" + mpich_version + "/mpich-" + mpich_version + ".tar.gz") elif "mvapich" in tool: print("") print("Downloading the source for mvapich-" + mvapich_version + " ..") print("") if not inOptions.skipOp: try: os.system( "wget http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-" + mvapich_version + ".tar.gz") except: print( "Invalid mvapich version passed. No Download link found." ) exit(1) else: print( "wget/ http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-" + mvapich_version + ".tar.gz") else: print("Skipping download of the source for the tools on request!") if inOptions.doInstall: print("NOTE: The downloads had better be there for the install!") ### print("\n\nC) Untar, configure, build and install each selected tool:\n") ### if inOptions.doInstall: if "gitdist" in commonToolsSelectedSet: print("\nInstalling gitdist ...") echoRunSysCmnd("cp " + pythonUtilsDir + "/gitdist " + common_tools_dir + "/") InstallProgramDriver.fixupInstallPermissions( inOptions, common_tools_dir) if "cmake" in commonToolsSelectedSet: os.system("tar -xf " + common_tools_dir + "/cmake-" + cmake_version + ".tar.gz") os.system("mv -f cmake-" + cmake_version + " " + common_tools_dir) os.system("yum install openssl-devel") if not inOptions.skipOp: try: os.system( "cmake " + common_tools_dir + "/cmake-" + cmake_version + " -DCMAKE_USE_OPENSSL=ON -DCMAKE_INSTALL_PREFIX=" + dev_env_base_dir + "/common_tools/cmake-" + cmake_version + "/") except: os.system("cmake " + common_tools_dir + "/cmake-" + cmake_version + " -DCMAKE_INSTALL_PREFIX=" + dev_env_base_dir + "/common_tools/cmake-" + cmake_version + "/") os.system("make -j8 install") os.system("cd ..") cmake_module = open(dev_env_dir + "/cmake-" + cmake_version, 'w+') cmake_module.write("#%Module\n\n") cmake_module.write("set version " + cmake_version + "\n") cmake_module.write( 'set name "MPACT Development Environment - 2.1.0"\n') cmake_module.write( 'set msg "Loads the development environment for MPACT."\n') cmake_module.write('\n') cmake_module.write("procs ModulesHelp { } {\n") cmake_module.write(" puts stderr $msg }\n\n") cmake_module.write("module-whatis $msg\n") cmake_module.write(common_tools_dir + "cmake-$version/bin\n") cmake_module.close() if "autoconf" in commonToolsSelectedSet: installToolFromSource("autoconf", autoconf_version_default, common_tools_dir, None, inOptions) if "gcc" in compilerToolsetSelectedSet: print("unpacking gcc-" + gcc_version + ".tar.gz...") os.system("tar xzf gcc-" + gcc_version + ".tar.gz") os.chdir("gcc-" + gcc_version) print("downloading gcc prerequisites...") os.system("./contrib/download_prerequisites") os.chdir(compiler_toolset_dir) os.system("mkdir gcc-" + gcc_version) os.chdir("gcc-" + gcc_version) print("configuring gcc...") os.system(scratch_dir + "/gcc-" + gcc_version + "/configure --disable-multilib --prefix=" + compiler_toolset_dir + "/gcc-" + gcc_version + " --enable-languages=c,c++,fortran") print("building gcc...") os.system("make -j8") os.system("make install") os.chdir(scratch_dir) if not inOptions.skipOp: gcc_module = open(dev_env_dir + "/gcc-" + gcc_version, 'w+') gcc_module.write("#%module\n\n") gcc_module.write("set root " + dev_env_base_dir + "\n") gcc_module.write("set version gcc-" + gcc_version + "\n") gcc_module.write("set tpldir " + compiler_toolset_base_dir + "/tpls\n") gcc_module.write( 'set name "MPACT Development Environment - $version"\n') gcc_module.write( 'set msg "Loads the development environment for MPACT."\n') gcc_module.write('proc ModulesHelp { } {\n') gcc_module.write(" puts stderr $msg }\n") gcc_module.write("module-whatis $msg\n") if not mvapichInstalled: gcc_module.write("if ![ is-loaded 'mpi/mpich-" + mpich_version + "-x86_64' ] {\n") gcc_module.write(" module load mpi/mpich-" + mpich_version + "-x86_64 }\n") else: gcc_module.write("if ![ is-loaded 'mpi/mvapich-" + mvapich_version + "-x86_64' ] {\n") gcc_module.write(" module load mpi/mvapich-" + mvapich_version + "-x86_64 }\n") gcc_module.write( "setenv TRIBITS_DEV_ENV_BASE $root\n") gcc_module.write( "setenv TRIBITS_DEV_ENV_GCC_VERSION $version\n") gcc_module.write( "setenv TRIBITS_DEV_ENV_COMPILER_BASE $root/$version\n") gcc_module.write( "setenv TRIBITS_DEV_ENV_MPICH_DIR $env(MPI_HOME)\n") gcc_module.write( "setenv LOADED_TRIBITS_DEV_ENV $version\n") gcc_module.write( "setenv LOADED_VERA_DEV_ENV $version\n") gcc_module.write("prepend-path PATH $root/common_tools\n") gcc_module.write("set tplpath $tpldir/hdf5-1.8.10\n") gcc_module.write("setenv HDF5_ROOT $tplpath\n") gcc_module.write("prepend-path PATH $tplpath/bin\n") gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n") gcc_module.write( "prepend-path INCLUDE $tplpath/include\n") gcc_module.write("set tplpath $tpldir/lapack-3.3.1\n") gcc_module.write("setenv BLAS_ROOT $tplpath\n") gcc_module.write("setenv LAPACK_DIR $tplpath\n") gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n") gcc_module.write("set tplpath $tpldir/hypre-2.9.1a\n") gcc_module.write("setenv HYPRE_DIR $tplpath\n") gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n") gcc_module.write("set tplpath $tpldir/petsc-3.5.4\n") gcc_module.write("setenv PETSC_DIR $tplpath\n") gcc_module.write("prepend-path PATH $tplpath/bin\n") gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n") gcc_module.write("set tplpath $tpldir/slepc-3.5.4\n") gcc_module.write("setenv SLEPC_DIR $tplpath\n") gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n") gcc_module.write("set tplpath $tpldir/sundials-2.9.0\n") gcc_module.write("setenv SUNDIALS_DIR $tplpath\n") gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n") gcc_module.write( "set-alias gitdist-status {gitdist dist-repo-status}\n" ) gcc_module.write( "set-alias gitdist-mod {gitdist --dist-mod-only}\n") gcc_module.close() if "mpich" in compilerToolsetSelectedSet: gccInstallDir = compiler_toolset_dir + "/gcc-" + gcc_version if not os.path.exists(gccInstallDir) and not inOptions.skipOp: raise Exception("Error, gcc has not been installed yet." \ " Missing directory '"+gccInstallDir+"'") LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "") if mpich_version == "3.1.3": installToolFromSource( "mpich", mpich_version, compiler_toolset_dir, { "CC": gccInstallDir + "/bin/gcc", "CXX": gccInstallDir + "/bin/g++", "FC": gccInstallDir + "/bin/gfortran", "LD_LIBRARY_PATH": compiler_toolset_dir + "/lib64:" + LD_LIBRARY_PATH }, inOptions) else: os.system("tar xfz mpich-" + mpich_version + ".tar.gz") os.system("mkdir -p " + compiler_toolset_dir + "/mpich-" + mpich_version) os.system("mkdir tmp") os.chdir("tmp") os.system("../mpich-" + mpich_version + "/configure -prefix=" + compiler_toolset_dir + "/mpich-" + mpich_version) os.system("make") os.system("make install") if not inOptions.skipOp: mpich_module = open(dev_env_dir + "/mpich-" + mpich_version, 'w+') mpich_module.write("conflict mvapich\n") mpich_module.write( "prepend-path PATH /usr/lib64/mpich/bin\n" ) mpich_module.write( "prepend-path LD_LIBRARY_PATH /usr/lib64/mpich/lib\n" ) mpich_module.write( "prepend-path PYTHONPATH /usr/lib64/python2.7/site-packages/mpich\n" ) mpich_module.write( "prepend-path MANPATH /usr/share/man/mpich-x86_64\n" ) mpich_module.write( "prepend-path PKG_CONFIG_PATH /usr/lib64/mpich/lib/pkgconfig\n" ) mpich_module.write( "setenv MPI_BIN /usr/lib64/mpich/bin\n" ) mpich_module.write( "setenv MPI_SYSCONFIG /etc/mpich-x86_64\n" ) mpich_module.write( "setenv MPI_FORTRAN_MOD_DIR /usr/lib64/gfortran/modules/mpich-x86_64\n" ) mpich_module.write( "setenv MPI_INCLUDE /usr/include/mpich-x86_64\n" ) mpich_module.write( "setenv MPI_LIB /usr/lib64/mpich/lib\n" ) mpich_module.write( "setenv MPI_MAN /usr/share/man/mpich-x86_64\n" ) mpich_module.write( "setenv MPI_PYTHON_SITEARCH /usr/lib64/python2.7/site-packages/mpich\n" ) mpich_module.write( "setenv MPI_COMPILER mpich-x86_64\n") mpich_module.write( "setenv MPI_SUFFIX _mpich\n") mpich_module.write( "setenv MPI_HOME /usr/lib64/mpich\n" ) mpich_module.close() elif "mvapich" in compilerToolsetSelectedSet: gccInstallDir = compiler_toolset_dir + "/gcc-" + gcc_version if not os.path.exists(gccInstallDir) and not inOptions.skipOp: raise Exception("Error, gcc has not been installed yet." \ " Missing directory '"+gccInstallDir+"'") LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "") mvapichDir = gccInstallDir + "/toolset/mvapich-" + mvapich_version if not inOptions.skipOp: os.system("yum install libibverbs") os.system("gzip -dc mvapich2-" + mvapich_version + ".tar.gz | tar -x") os.chdir("mvapich2-" + mvapich_version) os.system("./configure --prefix " + mvapichDir) os.system("make -j8") os.system("make install") mvapich_module = open( dev_env_dir + "/mvapich-" + mvapich_version, 'w+') mvapich_module.write("conflict mpich\n") mvapich_module.write( "prepend-path PATH /usr/lib64/mvapich2/bin\n" ) mvapich_module.write( "prepend-path LD_LIBRARY_PATH /usr/lib64/mvapich2/lib\n" ) mvapich_module.write( "prepend-path PYTHONPATH /usr/lib64/python2.7/site-packages/mvapich2\n" ) mvapich_module.write( "prepend-path MANPATH /usr/share/man/mvapich2-x86_64\n" ) mvapich_module.write( "prepend-path PKG_CONFIG_PATH /usr/lib64/mvapich2/lib/pkgconfig\n" ) mvapich_module.write( "setenv MPI_BIN /usr/lib64/mvapich2/bin\n" ) mvapich_module.write( "setenv MPI_SYSCONFIG /etc/mvapich2-x86_64\n" ) mvapich_module.write( "setenv MPI_FORTRAN_MOD_DIR /usr/lib64/gfortran/modules/mvapich2-x86_64\n" ) mvapich_module.write( "setenv MPI_INCLUDE /usr/include/mvapich2-x86_64\n" ) mvapich_module.write( "setenv MPI_LIB /usr/lib64/mvapich2/lib\n" ) mvapich_module.write( "setenv MPI_MAN /usr/share/man/mvapich2-x86_64\n" ) mvapich_module.write( "setenv MPI_PYTHON_SITEARCH /usr/lib64/python2.7/site-packages/mvapich2" ) mvapich_module.write( "setenv MPI_COMPILER mvapich2-x86_64\n" ) mvapich_module.write( "setenv MPI_SUFFIX _mvapich2\n") mvapich_module.write( "setenv MPI_HOME /usr/lib64/mvapich2" ) mvapich_module.close() else: print("Skipping install of the tools on request!") ### print("\n\nD) Final instructions for using installed dev env:") ### if inOptions.skipOp: print("\n***") print( "*** NOTE: --no-op provided, only traced actions that would have been taken!" ) print("***") else: os.system("mv load_dev_env.sh " + dev_env_dir) os.system("mv load_dev_env.csh " + dev_env_dir) print("installing CMake target for vera_tpls") if not inOptions.skipOp and inOptions.doInstall: os.system("mkdir " + compiler_toolset_base_dir + "/tpls") os.chdir(scratch_dir + "/..") os.system("git submodule init && git submodule update") if not os.path.exists(scratch_dir + "/tmp"): os.mkdir(scratch_dir + "/tmp") os.chdir(scratch_dir + "/tmp") os.system("rm -rf *") os.system("module load mpi") os.system( 'cmake -D CMAKE_INSTALL_PREFIX=' + compiler_toolset_base_dir + '/tpls -D CMAKE_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=mpicxx -D CMAKE_C_COMPILER=mpicc -D CMAKE_Fortran_COMPILER=mpif90 -D FFLAGS="-fPIC -O3" -D CFLAGS="-fPIC -O3" -D CXXFLAGS="-fPIC -O3" -D LDFLAGS="" -D ENABLE_SHARED=ON -D PROCS_INSTALL=8 ../../vera_tpls/TPL_build' ) os.system("make -j8 || make -j8") else: print("git submodule init && git submodule update") print( 'cmake -D CMAKE_INSTALL_PREFIX=' + compiler_toolset_base_dir + '/tpls -D CMAKE_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=mpicxx -D CMAKE_C_COMPILER=mpicc -D CMAKE_Fortran_COMPILER=mpif90 -D FFLAGS="-fPIC -O3" -D CFLAGS="-fPIC -O3" -D CXXFLAGS="-fPIC -O3" -D LDFLAGS="" -D ENABLE_SHARED=ON -D PROCS_INSTALL=8 ../vera_tpls/TPL_build' ) print("make -j8") if not inOptions.skipOp: if inOptions.build_image: print("building docker image") os.system("docker build -t test-mpact-dev-env " + dev_env_base_dir + "/images") if inOptions.showFinalInstructions: print("\nTo use the new dev env, just source the file:\n") print(" source " + dev_env_base_dir + "/env/load_dev_env.sh\n") print("for sh or bash shells (or load_dev_env.csh for csh shell).\n") print("TIP: Add this source to your ~/.bash_profile!") else: print("Skipping on request ...") print("\n[End]")
def main(cmndLineArgs): # # Get the command-line options # inOptions = getCmndLineOptions(cmndLineArgs) if inOptions.skipOp: print("\n***") print("*** NOTE: --no-op provided, will only trace actions and not touch the filesystem!") print("***\n") commonToolsSelected = \ getToolsSelectedArray(inOptions.commonTools, commonToolsArray) print("\nSelected common tools = " + commonToolsSelected) commonToolsSelectedSet = set(commonToolsSelected) compilerToolsetSelected = \ getToolsSelectedArray(inOptions.compilerToolset, compilerToolsetArray) print("\nSelected compiler toolset = " + compilerToolsetSelected) compilerToolsetSelectedSet = set(compilerToolsetSelected) gccVersion=gcc_version_default #ToDo: Make variable! dev_env_base_dir = inOptions.installDir ### print("\n\nA) Setup the install directory <dev_env_base> ='" + dev_env_base_dir + "':\n") ### dev_env_base_exists = os.path.exists(dev_env_base_dir) common_tools_dir = os.path.join(dev_env_base_dir, "common_tools") common_tools_exists = os.path.exists(common_tools_dir) compiler_toolset_base_dir = os.path.join(dev_env_base_dir, "gcc-"+gccVersion) compiler_toolset_base_exists = os.path.exists(compiler_toolset_base_dir) compiler_toolset_dir = os.path.join(compiler_toolset_base_dir, "toolset") compiler_toolset_exists = os.path.exists(compiler_toolset_dir) if inOptions.doInitialSetup: if not dev_env_base_exists: print("Creating directory '" + dev_env_base_dir + "' ...") if not inOptions.skipOp: os.makedirs(dev_env_base_dir) if not common_tools_exists: print("Creating directory '" + common_tools_dir + "' ...") if not inOptions.skipOp: os.makedirs(common_tools_dir) # Always create this directory so we can write the load_dev_env.sh script! if not compiler_toolset_base_exists: print("Creating directory '" + compiler_toolset_base_dir + "' ...") if not inOptions.skipOp: os.makedirs(compiler_toolset_base_dir) if not compiler_toolset_exists: print("Creating directory '" + compiler_toolset_dir + "' ...") if not inOptions.skipOp: os.makedirs(compiler_toolset_dir) print("Writing new files " + inOptions.loadDevEnvFileBaseName + ".[sh,csh] ...") if not inOptions.skipOp: writeLoadDevEnvFiles(dev_env_base_dir, compiler_toolset_base_dir, inOptions) else: print("Skipping setup of the install directory by request!") assertInstallDirExists(dev_env_base_dir, inOptions) assertInstallDirExists(common_tools_dir, inOptions) assertInstallDirExists(compiler_toolset_base_dir, inOptions) assertInstallDirExists(compiler_toolset_dir, inOptions) ### print("\n\nB) Download all sources for each selected tool:\n") ### if inOptions.doDownload: if "cmake" in commonToolsSelectedSet: downloadToolSource("cmake", cmake_version_default, inOptions.sourceGitUrlBase, inOptions) if "autoconf" in commonToolsSelectedSet: downloadToolSource("autoconf", autoconf_version_default, inOptions.sourceGitUrlBase, inOptions) if "gcc" in compilerToolsetSelectedSet: downloadToolSource("gcc", gcc_version_default, inOptions.sourceGitUrlBase, inOptions) if "mpich" in compilerToolsetSelectedSet: downloadToolSource("mpich", mpich_version_default, inOptions.sourceGitUrlBase, inOptions) else: print("Skipping download of the source for the tools on request!") if inOptions.doInstall: print("NOTE: The downloads had better be there for the install!") ### print("\n\nC) Untar, configure, build and install each selected tool:\n") ### if inOptions.doInstall: if "gitdist" in commonToolsSelectedSet: print("\nInstalling gitdist ...") echoRunSysCmnd("cp "+pythonUtilsDir+"/gitdist "+common_tools_dir+"/") InstallProgramDriver.fixupInstallPermissions(inOptions, common_tools_dir) if "cmake" in commonToolsSelectedSet: installToolFromSource("cmake", cmake_version_default, common_tools_dir, None, inOptions ) if "autoconf" in commonToolsSelectedSet: installToolFromSource("autoconf", autoconf_version_default, common_tools_dir, None, inOptions ) if "gcc" in compilerToolsetSelectedSet: installToolFromSource("gcc", gcc_version_default, compiler_toolset_dir, None, inOptions ) if "mpich" in compilerToolsetSelectedSet: gccInstallDir = compiler_toolset_dir+"/gcc-"+gcc_version_default if not os.path.exists(gccInstallDir) and not inOptions.skipOp: raise Exception("Error, gcc has not been installed yet." \ " Missing directory '"+gccInstallDir+"'") LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "") installToolFromSource( "mpich", mpich_version_default, compiler_toolset_dir, { "CC" : gccInstallDir+"/bin/gcc", "CXX" : gccInstallDir+"/bin/g++", "FC" : gccInstallDir+"/bin/gfortran", "LD_LIBRARY_PATH" : gccInstallDir+"/lib64:"+LD_LIBRARY_PATH }, inOptions ) else: print("Skipping install of the tools on request!") ### print("\n\nD) Final instructions for using installed dev env:") ### if inOptions.showFinalInstructions: print("\nTo use the new dev env, just source the file:\n") print(" source " + compiler_toolset_base_dir + "/load_dev_env.sh\n") print("for sh or bash shells (or load_dev_env.csh for csh shell).\n") print("TIP: Add this source to your ~/.bash_profile!") else: print("Skipping on request ...") if inOptions.skipOp: print("\n***") print("*** NOTE: --no-op provided, only traced actions that would have been taken!") print("***") print("\n[End]")