Improved codestyle conformancy to PEP8
This commit is contained in:
parent
94925221c1
commit
a6e549a2da
|
@ -3,6 +3,7 @@ import argparse
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
# set up two parsers: first parse config directory, and add dynamic arguments to full parser
|
# set up two parsers: first parse config directory, and add dynamic arguments to full parser
|
||||||
config_parser = argparse.ArgumentParser(add_help=False)
|
config_parser = argparse.ArgumentParser(add_help=False)
|
||||||
|
@ -29,7 +30,7 @@ def init():
|
||||||
parser.add_argument('--threads', help='Number of threads used for make [8]', default='8')
|
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 logile', action='store_true')
|
||||||
|
|
||||||
# run config parser and serach config/*.json to add a build and version argument for it to the full parser
|
# 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
|
config_dir = config_parser.parse_known_args()[0].config
|
||||||
for cf in glob.glob(config_dir+"/*.json"):
|
for cf in glob.glob(config_dir+"/*.json"):
|
||||||
with open(cf, 'r') as f:
|
with open(cf, 'r') as f:
|
||||||
|
|
|
@ -6,6 +6,7 @@ import glob
|
||||||
import shutil
|
import shutil
|
||||||
from lib.ui import bordered, underlined, progressbar
|
from lib.ui import bordered, underlined, progressbar
|
||||||
|
|
||||||
|
|
||||||
def install_lib(lib, src_dir, work_dir, inst_dir, comp_cc, comp_cxx, comp_fc, build_threads, verbose):
|
def install_lib(lib, src_dir, work_dir, inst_dir, comp_cc, comp_cxx, comp_fc, build_threads, verbose):
|
||||||
print(bordered("Installing " + lib['name'] + " v." + lib['version']))
|
print(bordered("Installing " + lib['name'] + " v." + lib['version']))
|
||||||
if not os.path.exists(src_dir):
|
if not os.path.exists(src_dir):
|
||||||
|
@ -19,7 +20,7 @@ def install_lib(lib,src_dir,work_dir,inst_dir,comp_cc,comp_cxx,comp_fc,build_thr
|
||||||
|
|
||||||
lib_name = lib['name']
|
lib_name = lib['name']
|
||||||
lib_version = lib['version']
|
lib_version = lib['version']
|
||||||
if verbose == False:
|
if not verbose:
|
||||||
logfile_path = work_dir + "/" + lib_name + "-" + lib_version + ".log"
|
logfile_path = work_dir + "/" + lib_name + "-" + lib_version + ".log"
|
||||||
if os.path.exists(logfile_path):
|
if os.path.exists(logfile_path):
|
||||||
os.remove(logfile_path)
|
os.remove(logfile_path)
|
||||||
|
@ -37,6 +38,7 @@ def install_lib(lib,src_dir,work_dir,inst_dir,comp_cc,comp_cxx,comp_fc,build_thr
|
||||||
print("Error: Download of "+lib_name+" v."+lib_version+" failed!")
|
print("Error: Download of "+lib_name+" v."+lib_version+" failed!")
|
||||||
print("See "+logfile_path+" for details")
|
print("See "+logfile_path+" for details")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# configure library
|
# configure library
|
||||||
os.chdir(work_dir)
|
os.chdir(work_dir)
|
||||||
if os.path.exists(work_dir+"/"+lib_name+"-"+lib_version):
|
if os.path.exists(work_dir+"/"+lib_name+"-"+lib_version):
|
||||||
|
@ -64,7 +66,7 @@ def install_lib(lib,src_dir,work_dir,inst_dir,comp_cc,comp_cxx,comp_fc,build_thr
|
||||||
build_task = subprocess.Popen(build_command, stdout=logfile, stderr=logfile, shell=True)
|
build_task = subprocess.Popen(build_command, stdout=logfile, stderr=logfile, shell=True)
|
||||||
num_objects = int(lib['object files'])
|
num_objects = int(lib['object files'])
|
||||||
finished = False
|
finished = False
|
||||||
while build_task.poll() == None:
|
while build_task.poll() is None:
|
||||||
if not finished:
|
if not finished:
|
||||||
# bar_width = num_objects
|
# bar_width = num_objects
|
||||||
# while (bar_width > 100):
|
# while (bar_width > 100):
|
||||||
|
@ -73,7 +75,7 @@ def install_lib(lib,src_dir,work_dir,inst_dir,comp_cc,comp_cxx,comp_fc,build_thr
|
||||||
for i in progressbar(range(num_objects), "Building library: ", bar_width):
|
for i in progressbar(range(num_objects), "Building library: ", bar_width):
|
||||||
while len(glob.glob('**/*.o', recursive=True)) < i:
|
while len(glob.glob('**/*.o', recursive=True)) < i:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
if(build_task.poll != None):
|
if build_task.poll is not None:
|
||||||
break
|
break
|
||||||
finished = True
|
finished = True
|
||||||
build_task.wait()
|
build_task.wait()
|
||||||
|
@ -100,4 +102,3 @@ def install_lib(lib,src_dir,work_dir,inst_dir,comp_cc,comp_cxx,comp_fc,build_thr
|
||||||
if not os.path.exists(build_output_path):
|
if not os.path.exists(build_output_path):
|
||||||
os.makedirs(build_output_path)
|
os.makedirs(build_output_path)
|
||||||
shutil.copyfile(logfile_path, build_output_path+"/"+lib_name+".log")
|
shutil.copyfile(logfile_path, build_output_path+"/"+lib_name+".log")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def get_from_command(command):
|
def get_from_command(command):
|
||||||
ret = subprocess.check_output(command).decode(sys.stdout.encoding)
|
ret = subprocess.check_output(command).decode(sys.stdout.encoding)
|
||||||
return ret
|
return ret
|
|
@ -19,6 +19,7 @@ def topological_sort(source):
|
||||||
emitted = next_emitted
|
emitted = next_emitted
|
||||||
return emitted
|
return emitted
|
||||||
|
|
||||||
|
|
||||||
def sort_libs_by_dependencies(selected_libs):
|
def sort_libs_by_dependencies(selected_libs):
|
||||||
deplist = []
|
deplist = []
|
||||||
for lib in selected_libs:
|
for lib in selected_libs:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from lib.shell import get_from_command
|
from lib.shell import get_from_command
|
||||||
|
|
||||||
|
|
||||||
def get_compiler_version(compiler):
|
def get_compiler_version(compiler):
|
||||||
if compiler == "gnu":
|
if compiler == "gnu":
|
||||||
cc = "gcc"
|
cc = "gcc"
|
||||||
|
@ -11,6 +12,7 @@ def get_compiler_version(compiler):
|
||||||
compstr = get_from_command([cc, "-dumpversion"]).strip()
|
compstr = get_from_command([cc, "-dumpversion"]).strip()
|
||||||
return compstr
|
return compstr
|
||||||
|
|
||||||
|
|
||||||
def get_mpi_version(mpi):
|
def get_mpi_version(mpi):
|
||||||
if mpi == "hpcx":
|
if mpi == "hpcx":
|
||||||
hpcx_dir = os.getenv('HPCX_DIR')
|
hpcx_dir = os.getenv('HPCX_DIR')
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def progressbar(it, prefix="", size=60, out=sys.stdout):
|
def progressbar(it, prefix="", size=60, out=sys.stdout):
|
||||||
count = len(it)
|
count = len(it)
|
||||||
|
|
||||||
def show(j):
|
def show(j):
|
||||||
x = int(size*j/count)
|
x = int(size*j/count)
|
||||||
print("{}[{}{}] {}/{}".format(prefix, u"█"*x, "."*(size-x), j, count),
|
print("{}[{}{}] {}/{}".format(prefix, u"█"*x, "."*(size-x), j, count), end='\r', file=out, flush=True)
|
||||||
end='\r', file=out, flush=True)
|
|
||||||
show(0)
|
show(0)
|
||||||
for i, item in enumerate(it):
|
for i, item in enumerate(it):
|
||||||
yield item
|
yield item
|
||||||
show(i+1)
|
show(i+1)
|
||||||
print("", flush=True, file=out)
|
print("", flush=True, file=out)
|
||||||
|
|
||||||
|
|
||||||
def bordered(text):
|
def bordered(text):
|
||||||
lines = text.splitlines()
|
lines = text.splitlines()
|
||||||
width = max(len(s) for s in lines)
|
width = max(len(s) for s in lines)
|
||||||
|
@ -22,6 +25,7 @@ def bordered(text):
|
||||||
res.append('└' + '─' * width + '┘')
|
res.append('└' + '─' * width + '┘')
|
||||||
return '\n'.join(res)
|
return '\n'.join(res)
|
||||||
|
|
||||||
|
|
||||||
def underlined(text):
|
def underlined(text):
|
||||||
lines = text.splitlines()
|
lines = text.splitlines()
|
||||||
width = max(len(s) for s in lines)
|
width = max(len(s) for s in lines)
|
||||||
|
@ -31,6 +35,7 @@ def underlined(text):
|
||||||
res.append('─' * width)
|
res.append('─' * width)
|
||||||
return '\n'.join(res)
|
return '\n'.join(res)
|
||||||
|
|
||||||
|
|
||||||
def print_welcome(script_version, compiler, compiler_version, mpi, mpi_version, instDir, installs):
|
def print_welcome(script_version, compiler, compiler_version, mpi, mpi_version, instDir, installs):
|
||||||
out = underlined("Patricks Simple Library Installer " + script_version)
|
out = underlined("Patricks Simple Library Installer " + script_version)
|
||||||
out = out + "\n" + "Compiler: " + compiler.upper() + ", Version: " + compiler_version
|
out = out + "\n" + "Compiler: " + compiler.upper() + ", Version: " + compiler_version
|
||||||
|
|
|
@ -29,9 +29,9 @@ verbose = arg_namespace.verbose
|
||||||
selected_libs = []
|
selected_libs = []
|
||||||
ignore_names = ["config", "mpi", "compiler", "prefix", "src", "work", "threads", "verbose", "version"]
|
ignore_names = ["config", "mpi", "compiler", "prefix", "src", "work", "threads", "verbose", "version"]
|
||||||
for lib_name in args:
|
for lib_name in args:
|
||||||
if (lib_name not in ignore_names and "version" not in lib_name):
|
if lib_name not in ignore_names and "version" not in lib_name:
|
||||||
install = getattr(arg_namespace, lib_name)
|
install = getattr(arg_namespace, lib_name)
|
||||||
if (install == True):
|
if install:
|
||||||
version = getattr(arg_namespace, lib_name+"_version")
|
version = getattr(arg_namespace, lib_name+"_version")
|
||||||
config_file = config_dir + "/" + lib_name + ".json"
|
config_file = config_dir + "/" + lib_name + ".json"
|
||||||
with open(config_file, 'r') as cf:
|
with open(config_file, 'r') as cf:
|
||||||
|
|
Loading…
Reference in New Issue