Commit ad9365b0 by heffnercj

Cleaned up setup.py; made C libraries optional; changed --ignore-prerequisites to --yes.

parent fba87c16
...@@ -5,50 +5,66 @@ import subprocess ...@@ -5,50 +5,66 @@ import subprocess
from os import listdir, path from os import listdir, path
from distutils.core import setup from distutils.core import setup
WIDTH = 115 # This is super hacky.
if "--yes" in sys.argv:
sys.argv.pop(sys.argv.index("--yes"))
IGNORE_WARNINGS = True
else:
IGNORE_WARNINGS = False
def which(fname): def which(fname):
cmd = ["which", fname] cmd = ["which", fname]
return subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.readline().strip() return subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.readline().strip()
def warning(lines, terminate=True, prompt=False):
WIDTH = 115
if not IGNORE_WARNINGS:
print "\n", "*" * WIDTH
for line in lines:
print line
print "*" * WIDTH, "\n"
if prompt:
if raw_input('Continue installation anyway (Y/n)? ').lower().startswith('n'):
terminate = True
else:
terminate = False
if terminate:
sys.exit(1)
# Check for pre-requisite modules only if --no-prereq-checks was not specified # Check for pre-requisite modules only if --no-prereq-checks was not specified
if "--no-prereq-checks" not in sys.argv: print "checking pre-requisites"
print "checking pre-requisites" try:
try:
import magic import magic
try: try:
magic.MAGIC_NO_CHECK_TEXT magic.MAGIC_NO_CHECK_TEXT
except Exception, e: except Exception, e:
print "\n", "*" * WIDTH msg = ["Pre-requisite failure:", str(e),
print "Pre-requisite failure:", str(e) "It looks like you have an old or incompatible magic module installed.",
print "It looks like you have an old or incompatible magic module installed." "Please install the official python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
print "Please install the official python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/" ]
print "*" * WIDTH, "\n"
sys.exit(1)
except Exception, e:
print "\n", "*" * WIDTH
print "Pre-requisite failure:", str(e)
print "Please install the python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
print "*" * WIDTH, "\n"
sys.exit(1)
try: warning(msg)
except Exception, e:
msg = ["Pre-requisite failure:", str(e),
"Please install the python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/",
]
warning(msg)
try:
import matplotlib import matplotlib
matplotlib.use('Agg') matplotlib.use('Agg')
import matplotlib.pyplot import matplotlib.pyplot
import numpy import numpy
except Exception, e: except Exception, e:
print "\n", "*" * WIDTH msg = ["Pre-requisite check warning:", str(e),
print "Pre-requisite check warning:", str(e) "To take advantage of this tool's entropy plotting capabilities, please install the python-matplotlib module.",
print "To take advantage of this tool's entropy plotting capabilities, please install the python-matplotlib module." ]
print "*" * WIDTH, "\n"
if raw_input('Continue installation without this module (Y/n)? ').lower().startswith('n'): warning(msg, prompt=True)
print 'Quitting...\n'
sys.exit(1)
else:
# This is super hacky.
sys.argv.pop(sys.argv.index("--no-prereq-checks"))
# Build / install C compression libraries # Build / install C compression libraries
c_lib_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "C") c_lib_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "C")
...@@ -64,11 +80,19 @@ if not os.path.exists(c_lib_makefile): ...@@ -64,11 +80,19 @@ if not os.path.exists(c_lib_makefile):
status |= os.system("make") status |= os.system("make")
if status != 0: if status != 0:
print "ERROR: Failed to build libtinfl.so! Do you have gcc installed?" msg = ["Failed to build compression libraries.",
sys.exit(1) "Some plugins will not work without these libraries."
]
warning(msg, prompt=True)
else:
if "install" in sys.argv:
if os.system("make install") != 0:
msg = ["Failed to install compression libraries.",
"Some plugins will not work without these libraries."
]
if "install" in sys.argv: warning(msg, prompt=True)
os.system("make install")
os.chdir(working_directory) os.chdir(working_directory)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment