libinstaller/lib/init.py

59 lines
4.0 KiB
Python
Raw Normal View History

import os
import argparse
import glob
import json
import sys
def check_python_version():
python_version = sys.version_info
if not (python_version.major >= 3 and python_version.minor >= 3):
print("Minimum Python version needed: 3.3.0")
sys.exit(1)
2022-09-22 01:51:47 +02:00
def init():
2022-09-22 01:51:47 +02:00
# set up two parsers: first parse config directory, and add dynamic arguments to full parser
config_parser = argparse.ArgumentParser(add_help=False)
parser = argparse.ArgumentParser()
# parsers need to share known arguments
2022-09-22 01:51:47 +02:00
config_parser.add_argument('--config', help='Path to config directory [$pwd/config]', default=os.getcwd()+"/config")
config_parser.add_argument('--prefix', help='Path where install directory should be generated [$pwd]', default=os.getcwd())
config_parser.add_argument('--src', help='Path where to download source code to [$pwd/src]', default=os.getcwd()+"/src")
config_parser.add_argument('--work', help='Path to working directory for builds [$pwd/work', default=os.getcwd()+"/work")
config_parser.add_argument('--keep-work', help='Disable removal of work directory after successful builds', action='store_true')
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 logfile', action='store_true')
2022-09-25 01:07:38 +02:00
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')
2022-09-22 01:51:47 +02:00
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")
parser.add_argument('--work', help='Path to working directory for builds [$pwd/work]', default=os.getcwd()+"/work")
parser.add_argument('--keep-work', help='Disable removal of work directory after successful builds', action='store_true')
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 logfile', action='store_true')
2022-09-25 01:07:38 +02:00
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')
2022-09-22 01:51:47 +02:00
# 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"):
with open(cf, 'r') as f:
lib_data = json.load(f)
2022-09-22 01:51:47 +02:00
parser.add_argument('--'+lib_data['name'], help='Enable build of '+lib_data['name'], action='store_true')
parser.add_argument('--'+lib_data['name']+'-version', help='Set '+lib_data['name']+' version ['+lib_data['default version']+']', default=str(lib_data['default version']))
# run full parser
arg_namespace = parser.parse_args()
args = vars(arg_namespace)
return arg_namespace, args