Spintrum/setup.py

274 lines
9.3 KiB
Python
Raw Permalink Normal View History

from distutils.command.build import build as _build
import os
import sys
import shutil
import errno
import tempfile
import subprocess
import glob
import re
import fnmatch
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
del os.link #solve hardlinking problem when using NTFS drive
script_dir = os.path.dirname(os.path.realpath(__file__))
start_working_dir = os.getcwd()
temp_dir = tempfile.gettempdir()
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()
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,))
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: