Skip to content
Snippets Groups Projects
Commit be8d9263 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Use `MANTIDPATH` environment variable if it is available

This allows for people using `mantidpython`. This change
also removes the ability to set the location of mantid from
the command line.
parent 19d5c011
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ def main(sysarg): ...@@ -40,7 +40,7 @@ def main(sysarg):
"Use -h for help" % ' '.join(args)) "Use -h for help" % ' '.join(args))
# Update sys path if we need to # Update sys path if we need to
update_path(opts.mantidpath) update_path()
# Find test files # Find test files
testpaths = find_test_files(SRC_DIR, opts.testinclude) testpaths = find_test_files(SRC_DIR, opts.testinclude)
...@@ -102,9 +102,6 @@ def parseargs(arglist): ...@@ -102,9 +102,6 @@ def parseargs(arglist):
""" """
parser = OptionParser(usage="Usage: %prog [options]", parser = OptionParser(usage="Usage: %prog [options]",
conflict_handler='error') conflict_handler='error')
parser.add_option("-m", "--mantidpath", dest="mantidpath",
help="Location of mantid package. Has no effect if run inside MantidPlot (default='%s')" % BUILD_DIR,
default=BUILD_DIR)
parser.add_option("-R", "--tests-regex", dest="testinclude", parser.add_option("-R", "--tests-regex", dest="testinclude",
help="Regex specifying which tests to run. It is matched against the " help="Regex specifying which tests to run. It is matched against the "
"filename when considering whether to run a test.") "filename when considering whether to run a test.")
...@@ -112,13 +109,10 @@ def parseargs(arglist): ...@@ -112,13 +109,10 @@ def parseargs(arglist):
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
def update_path(mantidpath): def update_path():
""" """
If not inside MantidPlot (current check is whether we can import _qti) If not inside MantidPlot (current check is whether we can import _qti)
then insert given path as first directory in sys.path then insert given path as first directory in sys.path
Args:
mantidpath (str): A string giving the location of the mantid module
""" """
try: try:
import _qti import _qti
...@@ -126,13 +120,19 @@ def update_path(mantidpath): ...@@ -126,13 +120,19 @@ def update_path(mantidpath):
except ImportError: except ImportError:
gui = False gui = False
# If it's MantidPlot then we already know what our paths should be so ignore it # If it's MantidPlot then we already know what our paths should be so ignore it
if gui: if gui:
return return
# add 'bin' if the subdirectory exists and isn't named # the python wrapper sets this environment variable
if os.path.split(mantidpath)[-1] != 'bin': mantidpath = os.environ.get('MANTIDPATH', None)
if os.path.isdir(os.path.join(mantidpath, 'bin')):
# otherwise try to expand based off of information in cmake
if mantidpath is None or len(mantidpath) == 0:
mantidpath = BUILD_DIR
if os.path.split(mantidpath)[-1] != 'bin' and \
os.path.isdir(os.path.join(mantidpath, 'bin')):
mantidpath = os.path.join(mantidpath, 'bin') mantidpath = os.path.join(mantidpath, 'bin')
# check for directory # check for directory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment