From dde53580f9c5049e4d32cdf9f50220c704234d49 Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Wed, 28 Sep 2022 15:40:49 +0200 Subject: [PATCH] v0.7 - intel mpi options corrected, added support for building all libraries at once --- lib/init.py | 14 ++++++++------ lib/toolchain.py | 14 +++++++------- libinstaller | 38 +++++++++++++++++++++++++------------- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/lib/init.py b/lib/init.py index 105a4c6..8c4abc2 100644 --- a/lib/init.py +++ b/lib/init.py @@ -25,10 +25,11 @@ def init(): config_parser.add_argument('--compiler', help='Select compiler (gnu, intel, aocc) [gnu]', default='gnu') config_parser.add_argument('--mpi', help='Select compiler (hpcx, intelmpi, openmpi) [hpcx]', default='hpcx') config_parser.add_argument('--threads', help='Number of threads used for make [8]', default='8') - config_parser.add_argument('--verbose', help='Print build output to screen instead piping it to logile', action='store_true') + config_parser.add_argument('--verbose', help='Print build output to screen instead piping it to logfile', action='store_true') config_parser.add_argument('--separate-lib64', help='Do not create symbolic links of files from lib64 in lib', action='store_true') config_parser.add_argument('--disable-shared', help='Disable building of shared libraries', action='store_true') - + config_parser.add_argument('--all', help='Install all libraries with config file in config/', action='store_true') + parser.add_argument('--config', help='Path to config directory [$pwd/config]', default=os.getcwd()+"/config") parser.add_argument('--prefix', help='Path where install directory should be generated [$pwd]', default=os.getcwd()) parser.add_argument('--src', help='Path where to download source code to [$pwd/src]', default=os.getcwd()+"/src") @@ -37,10 +38,11 @@ def init(): parser.add_argument('--compiler', help='Select compiler (gnu, intel, aocc) [gnu]', default='gnu') parser.add_argument('--mpi', help='Select compiler (hpcx, intelmpi, openmpi) [hpcx]', default='hpcx') parser.add_argument('--threads', help='Number of threads used for make [8]', default='8') - parser.add_argument('--verbose', help='Print build output to screen instead piping it to logile', action='store_true') + parser.add_argument('--verbose', help='Print build output to screen instead piping it to logfile', action='store_true') parser.add_argument('--separate-lib64', help='Do not create symbolic links of files from lib64 in lib', action='store_true') parser.add_argument('--disable-shared', help='Disable building of shared libraries', action='store_true') - + parser.add_argument('--all', help='Install all libraries with config file in config/', action='store_true') + # run config parser and search config/*.json to add a build and version argument for it to the full parser config_dir = config_parser.parse_known_args()[0].config for cf in glob.glob(config_dir+"/*.json"): @@ -52,5 +54,5 @@ def init(): # run full parser arg_namespace = parser.parse_args() args = vars(arg_namespace) - - return arg_namespace, args \ No newline at end of file + + return arg_namespace, args diff --git a/lib/toolchain.py b/lib/toolchain.py index de159fd..ec118c8 100644 --- a/lib/toolchain.py +++ b/lib/toolchain.py @@ -24,8 +24,8 @@ def get_mpi_version(mpi): rawstr = get_from_command(["ompi_info"]).splitlines()[1] mpistr = rawstr[rawstr.find(":")+2:] elif mpi == "intelmpi": - rawstr = get_from_command(["ompi_info"]).splitlines()[0] - mpistr = rawstr[rawstr.find("Version")+8:rawstr.find("Build")-1] + rawstr = get_from_command(["mpirun","--version"]) + mpistr = rawstr.split()[7] elif mpi == "mpich": rawstr = get_from_command(["mpirun", "--version"]) mpistr = rawstr.split()[4] @@ -38,7 +38,7 @@ def set_toolchain(compiler, mpi): cc = "mpicc" cxx = "mpic++" fc = "mpifort" - elif mpi == "intel": + elif mpi == "intelmpi": cc = "mpicc" cxx = "mpicxx" fc = "mpif90" @@ -52,7 +52,7 @@ def set_toolchain(compiler, mpi): os.environ["OMPI_MPIFC"] = "flang" os.environ["OMPI_MPIF90"] = "flang" os.environ["OMPI_MPIF77"] = "flang" - elif (mpi == "intel"): + elif (mpi == "intelmpi"): cc = "\"mpicc -cc=clang\"" cxx = "\"mpicxx -cxx=clang++\"" fc = "\"mpif90 -fc=flang\"" @@ -66,11 +66,11 @@ def set_toolchain(compiler, mpi): os.environ["OMPI_MPIFC"] = "ifort" os.environ["OMPI_MPIF90"] = "ifort" os.environ["OMPI_MPIF77"] = "ifort" - elif mpi == "intel": + elif mpi == "intelmpi": cc = "mpiicc" cxx = "mpiicpc" fc = "mpiifort" - + # set environment variables os.environ["CC"] = cc os.environ["CXX"] = cxx @@ -78,4 +78,4 @@ def set_toolchain(compiler, mpi): os.environ["F90"] = fc os.environ["F77"] = fc - return cc, cxx, fc \ No newline at end of file + return cc, cxx, fc diff --git a/libinstaller b/libinstaller index d803959..2790246 100755 --- a/libinstaller +++ b/libinstaller @@ -10,7 +10,7 @@ from lib.sort import sort_libs_by_dependencies from lib.installer import install_lib from lib.init import init, check_python_version -SCRIPT_VERSION = "v0.6" +SCRIPT_VERSION = "v0.7" # check if Python >=3.3.0 is used check_python_version() @@ -30,20 +30,28 @@ build_threads = arg_namespace.threads verbose = arg_namespace.verbose separate_lib64 = arg_namespace.separate_lib64 disable_shared = arg_namespace.disable_shared +install_all_libs = arg_namespace.all # extract libraries and versions selected for installation selected_libs = [] -ignore_names = ["config", "mpi", "compiler", "prefix", "src", "work", "threads", "verbose", "version", "disable_shared"] -for lib_name in args: - if lib_name not in ignore_names and "version" not in lib_name: - install = getattr(arg_namespace, lib_name) - if install: - version = getattr(arg_namespace, lib_name+"_version") - config_file = config_dir + "/" + lib_name + ".json" - with open(config_file, 'r') as cf: - data = json.load(cf) - data['version'] = version - selected_libs.append(data) +if install_all_libs: + for cf in glob.glob(config_dir+"/*.json"): + with open(cf, 'r') as f: + data = json.load(f) + data['version'] = data['default version'] + selected_libs.append(data) +else: + ignore_names = ["config", "mpi", "compiler", "prefix", "src", "work", "keep_work", "threads", "verbose", "version", "disable_shared"] + for lib_name in args: + if lib_name not in ignore_names and "version" not in lib_name: + install = getattr(arg_namespace, lib_name) + if install: + version = getattr(arg_namespace, lib_name+"_version") + config_file = config_dir + "/" + lib_name + ".json" + with open(config_file, 'r') as cf: + data = json.load(cf) + data['version'] = version + selected_libs.append(data) # set up install directory name compiler_version = get_compiler_version(compiler) @@ -62,6 +70,10 @@ print_welcome(SCRIPT_VERSION, compiler, compiler_version, mpi, mpi_version, buil # install selected libraries if len(sorted_libs) > 0: + # add install dir to environment + os.environ["LIBRARY_PATH"] = inst_dir + "/lib" + os.pathsep + inst_dir + "/lib64" + os.pathsep + os.environ["LIBRARY_PATH"] + os.environ["LD_LIBRARY_PATH"] = inst_dir + "/lib" + os.pathsep + inst_dir + "/lib64" + os.pathsep + os.environ["LD_LIBRARY_PATH"] + # install libraries for lib in sorted_libs: install_lib(lib, src_dir, work_dir, inst_dir, cc, cxx, fc, build_threads, disable_shared, verbose) print(bordered("ALL INSTALLS COMPLETED SUCCESSFULLY\nPlease add "+inst_dir+" to your environment")) @@ -84,4 +96,4 @@ if (not keep_work and os.path.exists(work_dir)): shutil.rmtree(work_dir) print("Done.") -print("\n") \ No newline at end of file +print("\n")