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()
# Check for pre-requisite modules only if --no-prereq-checks was not specified def warning(lines, terminate=True, prompt=False):
if "--no-prereq-checks" not in sys.argv: WIDTH = 115
print "checking pre-requisites"
try: if not IGNORE_WARNINGS:
import magic
try:
magic.MAGIC_NO_CHECK_TEXT
except Exception, e:
print "\n", "*" * WIDTH
print "Pre-requisite failure:", str(e)
print "It looks like you have an old or incompatible magic module installed."
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 "\n", "*" * WIDTH
print "Pre-requisite failure:", str(e) for line in lines:
print "Please install the python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/" print line
print "*" * WIDTH, "\n" print "*" * WIDTH, "\n"
sys.exit(1)
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
print "checking pre-requisites"
try:
import magic
try: try:
import matplotlib magic.MAGIC_NO_CHECK_TEXT
matplotlib.use('Agg')
import matplotlib.pyplot
import numpy
except Exception, e: except Exception, e:
print "\n", "*" * WIDTH msg = ["Pre-requisite failure:", str(e),
print "Pre-requisite check warning:", str(e) "It looks like you have an old or incompatible magic module installed.",
print "To take advantage of this tool's entropy plotting capabilities, please install the python-matplotlib module." "Please install the official python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
print "*" * WIDTH, "\n" ]
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/",
]
if raw_input('Continue installation without this module (Y/n)? ').lower().startswith('n'): warning(msg)
print 'Quitting...\n'
sys.exit(1) try:
else: import matplotlib
# This is super hacky. matplotlib.use('Agg')
sys.argv.pop(sys.argv.index("--no-prereq-checks")) import matplotlib.pyplot
import numpy
except Exception, e:
msg = ["Pre-requisite check warning:", str(e),
"To take advantage of this tool's entropy plotting capabilities, please install the python-matplotlib module.",
]
warning(msg, prompt=True)
# 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,12 +80,20 @@ if not os.path.exists(c_lib_makefile): ...@@ -64,12 +80,20 @@ 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."
]
if "install" in sys.argv:
os.system("make install") 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."
]
warning(msg, prompt=True)
os.chdir(working_directory) os.chdir(working_directory)
# Generate a new magic file from the files in the magic directory # Generate a new magic file from the files in the magic 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