Colored text and cleanup of setup.py

This commit is contained in:
Samer Afach 2017-01-12 20:25:21 +01:00
parent 44711b8389
commit dc18dadb4c
1 changed files with 14 additions and 8 deletions

View File

@ -1,7 +1,5 @@
from setuptools import setup, find_packages
from distutils.command.build import build as _build
from distutils.command.build_ext import build_ext as _build_ext
from setuptools import Extension
from spintrum import meta
import os
import sys
@ -73,7 +71,7 @@ def mkdir_p(path):
def deal_with_error_code(err_code, operation_name):
if err_code != 0:
sys.stderr.write("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(err_code) + ". Exiting!\n")
sys.exit(1)
@ -105,10 +103,14 @@ def clone_git_repository(dir, repos_link):
deal_with_error_code(err_code, "Cloning: " + repos_link)
print("Done cloning repository: " + repos_link)
question_color_start = "\x1b[0;37;44m"
color_end = "\x1b[0m"
def ask_openblas_optimization_level():
print("\n")
print("Which optimization option would you like to use to compile OpenBLAS?")
print(question_color_start +
"Which optimization option would you like to use to compile OpenBLAS?" +
color_end)
print("For more information on what the options mean, please visit:")
print("https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html")
print("1) -O2")
@ -116,7 +118,8 @@ def ask_openblas_optimization_level():
print("3) -Ofast")
print("4) Keep the default")
print("5) Skip compiling OpenBLAS and assume it exists in the system")
option_chosen = input("Please enter the option number: ")
sys.stdout.write("Please enter the option number: ")
option_chosen = input()
if option_chosen.replace(" ", "") == '1':
return "-O2"
elif option_chosen.replace(" ", "") == '2':
@ -133,7 +136,9 @@ def ask_openblas_optimization_level():
def ask_spintrum_optimization_level():
print("\n")
print("Which optimization option would you like to use to compile Spintrum?")
print(question_color_start +
"Which optimization option would you like to use to compile Spintrum?" +
color_end)
print("For more information on what the options mean, please visit:")
print("https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html")
print("1) -g")
@ -141,7 +146,8 @@ def ask_spintrum_optimization_level():
print("3) -O2")
print("4) -O3")
print("5) -Ofast")
option_chosen = input("Please enter the option number: ")
sys.stdout.write("Please enter the option number: ")
option_chosen = input("")
if option_chosen.replace(" ", "") == '1':
return "-g"
elif option_chosen.replace(" ", "") == '2':
@ -192,7 +198,7 @@ class DependenciesBuilder(_build):
clone_git_repository(openblas_full_path, openblas_git)
if openblas_target_optimization != "":
if not os.path.isdir(openblas_dir):
sys.stderr.write("Cannot open expected OpenBLAS directory " + openblas_dir + "\n")
_print_error("Cannot open expected OpenBLAS directory " + openblas_dir + "\n")
sys.exit(1)
makefiles_to_glob = os.path.join(openblas_dir, "Makefile*")