Index: run.py
===================================================================
--- run.py	(revision 0225a3fcdeccce342b5c26576640d8cdc6dd3ebd)
+++ run.py	(revision 0225a3fcdeccce342b5c26576640d8cdc6dd3ebd)
@@ -1,4 +1,5 @@
+# -*- coding: utf-8 -*-
 #!/usr/bin/env python
-# -*- coding: utf-8 -*-
+
 """
 Run sasview in place.  This allows sasview to use the python
@@ -14,5 +15,4 @@
 the given module or script.
 """
-from __future__ import print_function
 
 import imp
@@ -21,5 +21,6 @@
 from contextlib import contextmanager
 from os.path import join as joinpath
-from os.path import abspath, dirname
+from os.path import abspath, dirname, realpath
+
 
 def addpath(path):
@@ -63,5 +64,4 @@
     # build_path comes from context
     path = joinpath(build_path, *modname.split('.')) + ext
-    # print "importing", modname, "from", path
     return imp.load_dynamic(modname, path)
 
@@ -76,5 +76,6 @@
     # find the directories for the source and build
     from distutils.util import get_platform
-    root = abspath(dirname(__file__))
+    root = abspath(dirname(sys.argv[0]))
+
     platform = '%s-%s' % (get_platform(), sys.version[:3])
     build_path = joinpath(root, 'build', 'lib.' + platform)
@@ -103,12 +104,4 @@
         addpath(joinpath(root, '..', 'bumps'))
 
-    try:
-        import tinycc
-    except:
-        addpath(joinpath(root, '../tinycc/build/lib'))
-
-    # select wx version
-    #addpath(os.path.join(root, '..','wxPython-src-3.0.0.0','wxPython'))
-
     # Build project if the build directory does not already exist.
     if not os.path.exists(build_path):
@@ -123,6 +116,9 @@
     addpath(joinpath(root, '../sasmodels/'))
 
-    # The sas.models package Compiled Model files should be pulled in from the build directory even though
-    # the source is stored in src/sas/models.
+    # Import the sasview package from root/sasview as sas.sasview.  It would
+    # be better to just store the package in src/sas/sasview.
+    import sas
+    #sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview'))
+    sas.sasview = import_package('sas.sasview', joinpath(root, 'src','sas','sasview'))
 
     # Compiled modules need to be pulled from the build directory.
@@ -138,4 +134,6 @@
                                                      joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))
 
+    # Compiled modules need to be pulled from the build directory.
+    # Some packages are not where they are needed, so load them explicitly.
     import sas.sascalc.calculator
     sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core',
@@ -144,43 +142,15 @@
     sys.path.append(build_path)
 
-    set_git_tag()
-    # print "\n".join(sys.path)
-
-def set_git_tag():
-    try:
-        import subprocess
-        import os
-        import platform
-        FNULL = open(os.devnull, 'w')
-        if platform.system() == "Windows":
-            args = ['git', 'describe', '--tags']
-        else:
-            args = ['git describe --tags']
-        git_revision = subprocess.check_output(args, stderr=FNULL, shell=True)
-        import sas.sasview
-        sas.sasview.__build__ = str(git_revision).strip()
-    except subprocess.CalledProcessError as cpe:
-        get_logger().warning("Error while determining build number\n  Using command:\n %s \n Output:\n %s"% (cpe.cmd,cpe.output))
-
-_logger = None
-def get_logger():
-    global _logger
-    if _logger is None:
-        from sas.logger_config import SetupLogger
-        _logger = SetupLogger(__name__).config_development()
-    return _logger
-
 if __name__ == "__main__":
     # Need to add absolute path before actual prepare call,
     # so logging can be done during initialization process too
-    root = abspath(dirname(__file__))
-    addpath(joinpath(root, 'src'))
+    root = abspath(dirname(realpath(sys.argv[0])))
+    addpath(joinpath(root, 'src','sas'))
+    from logger_config import SetupLogger
+    logger = SetupLogger(__name__).config_development()
 
-    get_logger().debug("Starting SASVIEW in debug mode.")
+    logger.debug("Starting SASVIEW in debug mode.")
     prepare()
-    from sas.sasview.sasview import run_cli, run_gui
-    if len(sys.argv) == 1:
-        run_gui()
-    else:
-        run_cli()
-    get_logger().debug("Ending SASVIEW in debug mode.")
+    from sas.qtgui.MainWindow.MainWindow import run
+    run()
+    logger.debug("Ending SASVIEW in debug mode.")
