87 lines
3.0 KiB
Python
Executable File
87 lines
3.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import shutil
|
|
import json
|
|
import os
|
|
import glob
|
|
from lib.ui import progressbar, bordered, underlined, print_welcome
|
|
from lib.shell import get_from_command
|
|
from lib.toolchain import get_compiler_version, get_mpi_version, set_toolchain
|
|
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"
|
|
|
|
# check if Python >=3.3.0 is used
|
|
check_python_version()
|
|
|
|
# initialization by argparser
|
|
arg_namespace, args = init()
|
|
|
|
# extract known arguments from argparse namespace
|
|
prefix = arg_namespace.prefix
|
|
config_dir = arg_namespace.config
|
|
src_dir = arg_namespace.src
|
|
work_dir = arg_namespace.work
|
|
keep_work = arg_namespace.keep_work
|
|
compiler = arg_namespace.compiler
|
|
mpi = arg_namespace.mpi
|
|
build_threads = arg_namespace.threads
|
|
verbose = arg_namespace.verbose
|
|
separate_lib64 = arg_namespace.separate_lib64
|
|
disable_shared = arg_namespace.disable_shared
|
|
|
|
# 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)
|
|
|
|
# set up install directory name
|
|
compiler_version = get_compiler_version(compiler)
|
|
mpi_version = get_mpi_version(mpi)
|
|
inst_str = "inst-"+compiler + "_" + compiler_version + "_" + mpi + "_" + mpi_version
|
|
inst_dir = prefix + "/" + inst_str
|
|
|
|
# set up mpi wrappers and environment variables
|
|
cc, cxx, fc = set_toolchain(compiler, mpi)
|
|
|
|
# set up library install order by dependencies
|
|
sorted_libs = sort_libs_by_dependencies(selected_libs)
|
|
|
|
# print welcome screen
|
|
print_welcome(SCRIPT_VERSION, compiler, compiler_version, mpi, mpi_version, build_threads, disable_shared, inst_dir, sorted_libs)
|
|
|
|
# install selected libraries
|
|
if len(sorted_libs) > 0:
|
|
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"))
|
|
else:
|
|
print("NO LIBRARIES SELECTED FOR INSTALLATION")
|
|
|
|
# create symbolic links
|
|
if not separate_lib64:
|
|
lib_dir = inst_dir + "/lib"
|
|
lib64_dir = inst_dir + "/lib64"
|
|
if os.path.exists(lib_dir) and os.path.exists(lib64_dir):
|
|
print("Creating symbolic links...")
|
|
for file in glob.glob(lib64_dir+"/*.*"):
|
|
if not os.path.exists(file.replace("lib64","lib")):
|
|
os.symlink(file, file.replace("lib64","lib"))
|
|
|
|
# cleanup
|
|
if (not keep_work and os.path.exists(work_dir)):
|
|
print("Cleaning up work directory...")
|
|
shutil.rmtree(work_dir)
|
|
print("Done.")
|
|
|
|
print("\n") |