Prints fixing in setup.py
This commit is contained in:
parent
dc18dadb4c
commit
406913ce24
62
setup.py
62
setup.py
@ -24,7 +24,8 @@ temp_dir = tempfile.gettempdir()
|
|||||||
|
|
||||||
|
|
||||||
def _print_error(msg):
|
def _print_error(msg):
|
||||||
sys.stderr.write("\n\nERROR: " + msg + "\n\n\n")
|
sys.stderr.write("\n\n" + error_color_start + "ERROR: " + msg + color_end + " \n\n\n ")
|
||||||
|
sys.stderr.flush()
|
||||||
|
|
||||||
|
|
||||||
def which(program):
|
def which(program):
|
||||||
@ -73,7 +74,7 @@ def deal_with_error_code(err_code, operation_name):
|
|||||||
if err_code != 0:
|
if err_code != 0:
|
||||||
_print_error("A non-zero error code was returned at operation: " +
|
_print_error("A non-zero error code was returned at operation: " +
|
||||||
str(operation_name) + ". Code returned is: " +
|
str(operation_name) + ". Code returned is: " +
|
||||||
str(err_code) + ". Exiting!\n")
|
str(err_code) + ". Exiting!")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +105,7 @@ def clone_git_repository(dir, repos_link):
|
|||||||
print("Done cloning repository: " + repos_link)
|
print("Done cloning repository: " + repos_link)
|
||||||
|
|
||||||
question_color_start = "\x1b[0;37;44m"
|
question_color_start = "\x1b[0;37;44m"
|
||||||
|
error_color_start = "\x1b[0;37;41m"
|
||||||
color_end = "\x1b[0m"
|
color_end = "\x1b[0m"
|
||||||
|
|
||||||
def ask_openblas_optimization_level():
|
def ask_openblas_optimization_level():
|
||||||
@ -118,7 +120,8 @@ def ask_openblas_optimization_level():
|
|||||||
print("3) -Ofast")
|
print("3) -Ofast")
|
||||||
print("4) Keep the default")
|
print("4) Keep the default")
|
||||||
print("5) Skip compiling OpenBLAS and assume it exists in the system")
|
print("5) Skip compiling OpenBLAS and assume it exists in the system")
|
||||||
sys.stdout.write("Please enter the option number: ")
|
print(question_color_start + "Please enter the option number: " + color_end)
|
||||||
|
sys.stdout.flush()
|
||||||
option_chosen = input()
|
option_chosen = input()
|
||||||
if option_chosen.replace(" ", "") == '1':
|
if option_chosen.replace(" ", "") == '1':
|
||||||
return "-O2"
|
return "-O2"
|
||||||
@ -131,7 +134,7 @@ def ask_openblas_optimization_level():
|
|||||||
elif option_chosen.replace(" ", "") == '5':
|
elif option_chosen.replace(" ", "") == '5':
|
||||||
return "SKIPOPENBLAS"
|
return "SKIPOPENBLAS"
|
||||||
else:
|
else:
|
||||||
raise IndexError("Error: An unknown option was entered")
|
raise IndexError(error_color_start + "Error: An unknown option was entered" + color_end)
|
||||||
|
|
||||||
|
|
||||||
def ask_spintrum_optimization_level():
|
def ask_spintrum_optimization_level():
|
||||||
@ -146,7 +149,8 @@ def ask_spintrum_optimization_level():
|
|||||||
print("3) -O2")
|
print("3) -O2")
|
||||||
print("4) -O3")
|
print("4) -O3")
|
||||||
print("5) -Ofast")
|
print("5) -Ofast")
|
||||||
sys.stdout.write("Please enter the option number: ")
|
print(question_color_start + "Please enter the option number: " + color_end)
|
||||||
|
sys.stdout.flush()
|
||||||
option_chosen = input("")
|
option_chosen = input("")
|
||||||
if option_chosen.replace(" ", "") == '1':
|
if option_chosen.replace(" ", "") == '1':
|
||||||
return "-g"
|
return "-g"
|
||||||
@ -159,7 +163,7 @@ def ask_spintrum_optimization_level():
|
|||||||
elif option_chosen.replace(" ", "") == '5':
|
elif option_chosen.replace(" ", "") == '5':
|
||||||
return "-Ofast"
|
return "-Ofast"
|
||||||
else:
|
else:
|
||||||
raise IndexError("Error: An unknown option was entered")
|
raise IndexError(error_color_start + "Error: An unknown option was entered" + color_end)
|
||||||
|
|
||||||
|
|
||||||
def recursive_glob(rootdir, pattern='*'):
|
def recursive_glob(rootdir, pattern='*'):
|
||||||
@ -169,24 +173,8 @@ def recursive_glob(rootdir, pattern='*'):
|
|||||||
if fnmatch.fnmatch(filename, pattern)]
|
if fnmatch.fnmatch(filename, pattern)]
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
dir_name = "spintrum"
|
|
||||||
lib_file = "lib/libspintrum.so"
|
|
||||||
|
|
||||||
|
def get_openblas():
|
||||||
class DependenciesBuilder(_build):
|
|
||||||
def run(self):
|
|
||||||
if sys.platform.startswith('win'):
|
|
||||||
_print_error("You cannot build Spintrum on Windows. It is not supported.")
|
|
||||||
|
|
||||||
python_version = float(str(sys.version_info[0]) + "." + str(sys.version_info[1]))
|
|
||||||
if python_version < 3.3:
|
|
||||||
_print_error("You must have python version >= 3.3 to use Spintrum")
|
|
||||||
|
|
||||||
check_programs_availability(["cmake","make","g++","gcc","gfortran","git","python3"])
|
|
||||||
|
|
||||||
print("Building Spintrum C/C++ extension prerequisites")
|
|
||||||
|
|
||||||
########## get OpenBLAS
|
|
||||||
openblas_dir = "3rdparty/OpenBLAS"
|
openblas_dir = "3rdparty/OpenBLAS"
|
||||||
openblas_dir_install = "spintrum/OpenBLAS_install"
|
openblas_dir_install = "spintrum/OpenBLAS_install"
|
||||||
openblas_full_path = os.path.join(start_working_dir, openblas_dir)
|
openblas_full_path = os.path.join(start_working_dir, openblas_dir)
|
||||||
@ -198,7 +186,7 @@ class DependenciesBuilder(_build):
|
|||||||
clone_git_repository(openblas_full_path, openblas_git)
|
clone_git_repository(openblas_full_path, openblas_git)
|
||||||
if openblas_target_optimization != "":
|
if openblas_target_optimization != "":
|
||||||
if not os.path.isdir(openblas_dir):
|
if not os.path.isdir(openblas_dir):
|
||||||
_print_error("Cannot open expected OpenBLAS directory " + openblas_dir + "\n")
|
_print_error("Cannot open expected OpenBLAS directory " + openblas_dir)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
makefiles_to_glob = os.path.join(openblas_dir, "Makefile*")
|
makefiles_to_glob = os.path.join(openblas_dir, "Makefile*")
|
||||||
@ -222,6 +210,28 @@ class DependenciesBuilder(_build):
|
|||||||
deal_with_error_code(install_openblas_err_code, "Installing OpenBLAS")
|
deal_with_error_code(install_openblas_err_code, "Installing OpenBLAS")
|
||||||
os.chdir(start_working_dir) # restore working dir
|
os.chdir(start_working_dir) # restore working dir
|
||||||
|
|
||||||
|
|
||||||
|
dir_name = "spintrum"
|
||||||
|
lib_file = "lib/libspintrum.so"
|
||||||
|
|
||||||
|
|
||||||
|
class DependenciesBuilder(_build):
|
||||||
|
def run(self):
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stderr.flush()
|
||||||
|
if sys.platform.startswith('win'):
|
||||||
|
_print_error("You cannot build Spintrum on Windows. It is not supported.")
|
||||||
|
|
||||||
|
python_version = float(str(sys.version_info[0]) + "." + str(sys.version_info[1]))
|
||||||
|
if python_version < 3.3:
|
||||||
|
_print_error("You must have python version >= 3.3 to use Spintrum")
|
||||||
|
|
||||||
|
check_programs_availability(["cmake","make","g++","gcc","gfortran","git","python3"])
|
||||||
|
|
||||||
|
print("Building Spintrum C/C++ extension prerequisites")
|
||||||
|
|
||||||
|
get_openblas()
|
||||||
|
|
||||||
############## get Polymath
|
############## get Polymath
|
||||||
polymath_git = "https://git.afach.de/samerafach/Polymath"
|
polymath_git = "https://git.afach.de/samerafach/Polymath"
|
||||||
polymath_dir = "3rdparty/Polymath"
|
polymath_dir = "3rdparty/Polymath"
|
||||||
@ -230,12 +240,12 @@ class DependenciesBuilder(_build):
|
|||||||
|
|
||||||
############## build spintrum
|
############## build spintrum
|
||||||
spintrum_optimization_target = ask_spintrum_optimization_level()
|
spintrum_optimization_target = ask_spintrum_optimization_level()
|
||||||
print("Building Spintrum")
|
print("Building Spintrum extension...")
|
||||||
err_code = subprocess.call(["cmake . -DPythonInstallation=1 -DOptimizationLevel=" + spintrum_optimization_target], shell=True)
|
err_code = subprocess.call(["cmake . -DPythonInstallation=1 -DOptimizationLevel=" + spintrum_optimization_target], shell=True)
|
||||||
deal_with_error_code(err_code, "CMaking spintrum")
|
deal_with_error_code(err_code, "CMaking spintrum")
|
||||||
err_code = subprocess.call(["make"], shell=True)
|
err_code = subprocess.call(["make"], shell=True)
|
||||||
deal_with_error_code(err_code, "Making spintrum")
|
deal_with_error_code(err_code, "Making spintrum")
|
||||||
print("Done building spintrum.")
|
print("Done building spintrum extension.")
|
||||||
|
|
||||||
|
|
||||||
setup(name='spintrum',
|
setup(name='spintrum',
|
||||||
|
Loading…
Reference in New Issue
Block a user