diff --git a/docs/runsphinx.py.in b/docs/runsphinx.py.in index 945c287801f008c118a9bc74504f9ef8ad5b1b00..affe9cf411f97347f76610c4329364ddd7b18b82 100644 --- a/docs/runsphinx.py.in +++ b/docs/runsphinx.py.in @@ -40,7 +40,7 @@ def main(sysarg): "Use -h for help" % ' '.join(args)) # Update sys path if we need to - update_path(opts.mantidpath) + update_path() # Find test files testpaths = find_test_files(SRC_DIR, opts.testinclude) @@ -102,9 +102,6 @@ def parseargs(arglist): """ parser = OptionParser(usage="Usage: %prog [options]", 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", help="Regex specifying which tests to run. It is matched against the " "filename when considering whether to run a test.") @@ -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) then insert given path as first directory in sys.path - - Args: - mantidpath (str): A string giving the location of the mantid module """ try: import _qti @@ -126,13 +120,19 @@ def update_path(mantidpath): except ImportError: gui = False + # If it's MantidPlot then we already know what our paths should be so ignore it if gui: return - # add 'bin' if the subdirectory exists and isn't named - if os.path.split(mantidpath)[-1] != 'bin': - if os.path.isdir(os.path.join(mantidpath, 'bin')): + # the python wrapper sets this environment variable + mantidpath = os.environ.get('MANTIDPATH', None) + + # 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') # check for directory