2017-01-12 18:21:29 +01:00
|
|
|
from distutils.command.build import build as _build
|
2017-01-10 11:14:51 +01:00
|
|
|
import os
|
|
|
|
import sys
|
2017-01-12 18:21:29 +01:00
|
|
|
import shutil
|
|
|
|
import errno
|
|
|
|
import tempfile
|
|
|
|
import subprocess
|
|
|
|
import glob
|
2017-01-13 10:57:12 +01:00
|
|
|
import re
|
2017-01-12 18:21:29 +01:00
|
|
|
import fnmatch
|
|
|
|
|
|
|
|
try:
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.extension import Extension
|
2017-01-10 11:14:51 +01:00
|
|
|
|
|
|
|
del os.link #solve hardlinking problem when using NTFS drive
|
|
|
|
|
2017-01-12 18:21:29 +01:00
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
start_working_dir = os.getcwd()
|
|
|
|
temp_dir = tempfile.gettempdir()
|
|
|
|
|
|
|
|
|
2017-01-10 11:14:51 +01:00
|
|
|
def _print_error(msg):
|
2017-01-12 20:49:24 +01:00
|
|
|
sys.stderr.write("\n\n" + error_color_start + "ERROR: " + msg + color_end + " \n\n\n ")
|
|
|
|
sys.stderr.flush()
|
2017-01-10 11:14:51 +01:00
|
|
|
|
2017-01-13 10:57:12 +01:00
|
|
|
def get_version():
|
|
|
|
VERSIONFILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),"spintrum/meta.py")
|
|
|
|
verstrline = open(VERSIONFILE, "rt").read()
|
|
|
|
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
|
|
|
mo = re.search(VSRE, verstrline, re.M)
|
|
|
|
if mo:
|
|
|
|
return str(mo.group(1))
|
|
|
|
else:
|
|
|
|
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
|
2017-01-12 18:21:29 +01:00
|
|
|
|
|
|
|
def which(program):
|
|
|
|
"""
|
|
|
|
Checks if a program exists, and returns its path
|
|
|
|
:param program: global program name
|
|
|
|
:return: program path if it exists, otherwise None
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
def is_exe(fpath):
|
|
|
|
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
|
|
|
|
|
|
|
fpath, fname = os.path.split(program)
|
|
|
|
if fpath:
|
|
|
|
if is_exe(program):
|
|
|
|
return program
|
|
|
|
else:
|
|
|
|
for path in os.environ["PATH"].split(os.pathsep):
|
|
|
|
path = path.strip('"')
|
|
|
|
exe_file = os.path.join(path, program)
|
|
|
|
if is_exe(exe_file):
|
|
|
|
return exe_file
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def check_programs_availability(list_of_programs):
|
|
|
|
for prog in list_of_programs:
|
|