Changeset 899e084 in sasview


Ignore:
Timestamp:
Jun 27, 2016 7:36:41 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
80c2c85
Parents:
efe730d
Message:

build console app as well as gui

Files:
2 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • run.py

    refe730d r899e084  
    126126if __name__ == "__main__": 
    127127    prepare() 
    128     from sas.sasview.sasview import run 
    129     run() 
     128    from sas.sasview.sasview import run_gui 
     129    run_gui() 
  • sasview/installer_generator.py

    refe730d r899e084  
    44exists in the current directory. Edit local_config.py according to your needs. 
    55""" 
     6import os 
     7import sys 
     8import string 
     9 
     10root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
     11sys.path.insert(0, os.path.join(root, 'sasview-install', 'Lib', 'site-packages')) 
    612from sas.sasview import local_config 
    7 import os  
    8 import string 
    913 
    1014REG_PROGRAM = """{app}\MYPROG.EXE"" ""%1""" 
     
    1317AppVerName = str(local_config.__appname__ )+'-'+ str(local_config.__version__) 
    1418Dev = '' 
    15 if AppVerName.lower().count('dev') > 0: 
     19if 'dev' in AppVerName.lower(): 
    1620    Dev = '-Dev' 
    1721AppPublisher = local_config._copyright 
  • sasview/setup_exe.py

    refe730d r899e084  
    3333root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
    3434platform = '%s-%s'%(get_platform(), sys.version[:3]) 
    35 build_path = os.path.join(root, 'build', 'lib.'+platform) 
    36 #build_path = os.path.join(root, 'sasview-install', 'Lib', 'site-packages') 
     35build_path = os.path.join(root, 'sasview-install', 'Lib', 'site-packages') 
    3736sys.path.insert(0, build_path) 
     37doc_path = os.path.join(root, 'build', 'lib.'+platform, 'doc') 
    3838 
    3939from sas.sasview import local_config 
     
    279279 
    280280# See if the documentation has been built, and if so include it. 
    281 doc_path = os.path.join(build_path, "doc") 
    282281if os.path.exists(doc_path): 
    283282    for dirpath, dirnames, filenames in os.walk(doc_path): 
     
    314313    ]) 
    315314packages.append('periodictable.core') # not found automatically 
    316 #packages.append('IPython') 
     315# For an interactive interpreter, SasViewCom 
     316packages.extend(['IPython','pyreadline','pyreadline.unicode_helper']) 
     317 
     318# individual models 
    317319includes = ['site', 'lxml._elementpath', 'lxml.etree'] 
    318320 
     
    329331    'tcl84.dll', 'tk84.dll', 'QtGui4.dll', 'QtCore4.dll', 
    330332    # numpy 1.8 openmp bindings (still seems to use all the cores without them) 
    331     'libiomp5md.dll', 'libifcoremd.dll', 'libmmd.dll', 'svml_dispmd.dll','libifportMD.dll', 
     333    # ... but we seem to need them when building from anaconda, so don't exclude ... 
     334    #'libiomp5md.dll', 'libifcoremd.dll', 'libmmd.dll', 'svml_dispmd.dll','libifportMD.dll', 
    332335    # microsoft C runtime (not allowed to ship with the app; need to ship vcredist 
    333336    'msvcp90.dll', 
     
    340343    ] 
    341344 
     345# extra dlls not found automatically 
     346python_root = os.path.dirname(os.path.abspath(sys.executable)) 
     347dll_path = os.path.join(python_root, 'Library', 'bin') 
     348# the following are found already: 'mkl_intel_thread', 'libmmd', 'libifcoremd' 
     349dll_includes = ['mkl_core', 'mkl_def', 'libiomp5md'] 
     350dll_includes = [os.path.join(dll_path, dll+'.dll') for dll in dll_includes] 
     351dll_includes = [dll for dll in dll_includes if os.path.exists(dll)] 
     352if dll_includes: 
     353   DATA_FILES.append(('.', dll_includes)) 
     354 
    342355target_wx_client = Target( 
    343356    description = 'SasView', 
    344     script = 'startup.py', 
     357    script = 'sasview_gui.py', 
    345358    icon_resources = [(1, local_config.SetupIconFile_win)], 
    346359    other_resources = [(24, 1, manifest)], 
    347360    dest_base = "SasView" 
    348361    ) 
     362 
     363target_console_client = Target( 
     364    description = 'SasView console', 
     365    script = 'sasview_console.py', 
     366    icon_resources = [(1, local_config.SetupIconFile_win)], 
     367    other_resources = [(24, 1, manifest)], 
     368    dest_base = "SasViewCom" 
     369) 
    349370 
    350371bundle_option = 2 
     
    358379setup( 
    359380    windows=[target_wx_client], 
    360     console=[], 
     381    console=[target_console_client], 
    361382    options={ 
    362383        'py2exe': { 
  • sasview/setup_mac.py

    refe730d r899e084  
    175175APPNAME = "SasView "+VERSION 
    176176DMGNAME = "SasView-"+VERSION+"-MacOSX" 
    177 APP = ['sasview.py'] 
     177APP = ['sasview_gui.py'] 
    178178 
    179179EXCLUDES = ['PyQt4', 'sip', 'QtGui'] 
  • setup.py

    refe730d r899e084  
    5656    #             file_path =  os.path.join(f_path, f) 
    5757    #             os.remove(file_path) 
    58     if os.path.exists(SASVIEW_BUILD): 
    59         print "Removing existing build directory", SASVIEW_BUILD, "for a clean build" 
    60         shutil.rmtree(SASVIEW_BUILD) 
     58 
     59if os.path.exists(SASVIEW_BUILD): 
     60    print "Removing existing build directory", SASVIEW_BUILD, "for a clean build" 
     61    shutil.rmtree(SASVIEW_BUILD) 
    6162                     
    6263# 'sys.maxsize' and 64bit: Not supported for python2.5 
    63 is_64bits = False 
    64 if sys.version_info >= (2, 6): 
    65     is_64bits = sys.maxsize > 2**32 
    66      
     64is_64bits = sys.maxsize > 2**32 
    6765enable_openmp = False 
    6866 
     
    338336    zip_safe = False, 
    339337    entry_points = { 
    340                     'console_scripts':[ 
    341                                        "sasview = sas.sasview.sasview:run", 
    342                                        ] 
    343                     }, 
    344     cmdclass = {'build_ext': build_ext_subclass, 
    345                 'docs': BuildSphinxCommand, 
    346                 'disable_openmp': DisableOpenMPCommand} 
     338        'console_scripts': ["sasview = sas.sasview.sasview:run_cli"] 
     339        }, 
     340    cmdclass = { 
     341        'build_ext': build_ext_subclass, 
     342        'docs': BuildSphinxCommand, 
     343        'disable_openmp': DisableOpenMPCommand, 
     344        } 
    347345    )    
  • src/sas/sasview/__init__.py

    refe730d r899e084  
    1 __version__ = "4.0.0-a3" 
     1__version__ = "4.0.0a4" 
    22__build__ = "1" 
  • src/sas/sasview/sasview.py

    refe730d r899e084  
    1616import traceback 
    1717 
    18 log_file = os.path.join(os.path.expanduser("~"), 'sasview.log') 
    19 logging.basicConfig(level=logging.INFO, 
    20                     format='%(asctime)s %(levelname)s %(message)s', 
    21                     filename=log_file, 
    22 ) 
    23 logging.captureWarnings(True) 
     18 
     19reload(sys) 
     20sys.setdefaultencoding("iso-8859-1") 
     21 
    2422 
    2523class StreamToLogger(object): 
     
    4139            self.logger.log(self.log_level, line.rstrip()) 
    4240 
    43 stderr_logger = logging.getLogger('STDERR') 
    44 sl = StreamToLogger(stderr_logger, logging.ERROR) 
    45 sys.stderr = sl 
    46  
    47 # Log the start of the session 
    48 logging.info(" --- SasView session started ---") 
    49  
    50 # Log the python version 
    51 logging.info("Python: %s" % sys.version) 
    52  
    53 # Allow the dynamic selection of wxPython via an environment variable, when devs 
    54 # who have multiple versions of the module installed want to pick between them. 
    55 # This variable does not have to be set of course, and through normal usage will 
    56 # probably not be, but this can make things a little easier when upgrading to a 
    57 # new version of wx. 
    58 WX_ENV_VAR = "SASVIEW_WX_VERSION" 
    59 if WX_ENV_VAR in os.environ: 
    60     logging.info("You have set the %s environment variable to %s." % \ 
    61                  (WX_ENV_VAR, os.environ[WX_ENV_VAR])) 
    62     import wxversion 
    63     if wxversion.checkInstalled(os.environ[WX_ENV_VAR]): 
    64         logging.info("Version %s of wxPython is installed, so using that version." % os.environ[WX_ENV_VAR]) 
    65         wxversion.select(os.environ[WX_ENV_VAR]) 
    66     else: 
    67         logging.error("Version %s of wxPython is not installed, so using default version." % os.environ[WX_ENV_VAR]) 
    68 else: 
    69     logging.info("You have not set the %s environment variable, so using default version of wxPython." % WX_ENV_VAR) 
    70  
    71 import wx 
    72  
    73 try: 
    74     logging.info("Wx version: %s" % wx.__version__) 
    75 except: 
    76     logging.error("Wx version: error reading version") 
    77  
    78 from . import wxcruft 
    79 wxcruft.call_later_fix() 
    80 #wxcruft.trace_new_id() 
    81 #Always use private .matplotlib setup to avoid conflicts with other 
    82 #uses of matplotlib 
    83  
    84 import sas.sasgui 
    85 mplconfigdir = os.path.join(sas.sasgui.get_user_dir(), '.matplotlib') 
    86 if not os.path.exists(mplconfigdir): 
    87     os.mkdir(mplconfigdir) 
    88 os.environ['MPLCONFIGDIR'] = mplconfigdir 
    89 reload(sys) 
    90 sys.setdefaultencoding("iso-8859-1") 
    91  
    92  
    93 from sas.sasgui.guiframe import gui_manager 
    94 from .welcome_panel import WelcomePanel 
    9541PLUGIN_MODEL_DIR = 'plugin_models' 
    9642APP_NAME = 'SasView' 
     
    10349        """ 
    10450        """ 
    105         #from gui_manager import ViewApp 
    106         self.gui = gui_manager.SasViewApp(0) 
     51        from sas.sasgui.guiframe.gui_manager import SasViewApp 
     52        self.gui = SasViewApp(0) 
    10753        # Set the application manager for the GUI 
    10854        self.gui.set_manager(self) 
     
    11662        # Fitting perspective 
    11763        try: 
    118             import sas.sasgui.perspectives.fitting as module     
     64            import sas.sasgui.perspectives.fitting as module 
    11965            fitting_plug = module.Plugin() 
    12066            self.gui.add_perspective(fitting_plug) 
     
    14288            logging.error(traceback.format_exc()) 
    14389 
    144         #Calculator perspective    
     90        #Calculator perspective 
    14591        try: 
    14692            import sas.sasgui.perspectives.calculator as module 
     
    154100 
    155101        # Add welcome page 
     102        from .welcome_panel import WelcomePanel 
    156103        self.gui.set_welcome_panel(WelcomePanel) 
    157104 
     
    164111 
    165112 
    166 def run(): 
     113def setup_logging(): 
     114    log_file = os.path.join(os.path.expanduser("~"), 'sasview.log') 
     115    logging.basicConfig(level=logging.INFO, 
     116                        format='%(asctime)s %(levelname)s %(message)s', 
     117                        filename=log_file, 
     118                        ) 
     119    logging.captureWarnings(True) 
     120 
     121    stderr_logger = logging.getLogger('STDERR') 
     122    sl = StreamToLogger(stderr_logger, logging.ERROR) 
     123    sys.stderr = sl 
     124 
     125    # Log the start of the session 
     126    logging.info(" --- SasView session started ---") 
     127 
     128    # Log the python version 
     129    logging.info("Python: %s" % sys.version) 
     130 
     131 
     132def setup_wx(): 
     133    # Allow the dynamic selection of wxPython via an environment variable, when devs 
     134    # who have multiple versions of the module installed want to pick between them. 
     135    # This variable does not have to be set of course, and through normal usage will 
     136    # probably not be, but this can make things a little easier when upgrading to a 
     137    # new version of wx. 
     138    WX_ENV_VAR = "SASVIEW_WX_VERSION" 
     139    if WX_ENV_VAR in os.environ: 
     140        logging.info("You have set the %s environment variable to %s." % \ 
     141                     (WX_ENV_VAR, os.environ[WX_ENV_VAR])) 
     142        import wxversion 
     143        if wxversion.checkInstalled(os.environ[WX_ENV_VAR]): 
     144            logging.info("Version %s of wxPython is installed, so using that version." % os.environ[WX_ENV_VAR]) 
     145            wxversion.select(os.environ[WX_ENV_VAR]) 
     146        else: 
     147            logging.error("Version %s of wxPython is not installed, so using default version." % os.environ[WX_ENV_VAR]) 
     148    else: 
     149        logging.info("You have not set the %s environment variable, so using default version of wxPython." % WX_ENV_VAR) 
     150 
     151    import wx 
     152 
     153    try: 
     154        logging.info("Wx version: %s" % wx.__version__) 
     155    except: 
     156        logging.error("Wx version: error reading version") 
     157 
     158    from . import wxcruft 
     159    wxcruft.call_later_fix() 
     160    #wxcruft.trace_new_id() 
     161    #Always use private .matplotlib setup to avoid conflicts with other 
     162    #uses of matplotlib 
     163 
     164 
     165def setup_mpl(): 
     166    import sas.sasgui 
     167    mplconfigdir = os.path.join(sas.sasgui.get_user_dir(), '.matplotlib') 
     168    if not os.path.exists(mplconfigdir): 
     169        os.mkdir(mplconfigdir) 
     170    os.environ['MPLCONFIGDIR'] = mplconfigdir 
     171    # Set backend to WXAgg; this overrides matplotlibrc, but shouldn't override 
     172    # mpl.use().  Note: Don't import matplotlib here since the script that 
     173    # we are running may not actually need it; also, putting as little on the 
     174    # path as we can 
     175    os.environ['MPLBACKEND'] = 'WXAgg' 
     176 
     177 
     178def run_gui(): 
    167179    """ 
    168180    __main__ method for loading and running SasView 
     
    170182    from multiprocessing import freeze_support 
    171183    freeze_support() 
    172     if len(sys.argv) > 1: 
    173         ## Run sasview as an interactive python interpreter 
    174         if sys.argv[1] == "-i": 
    175             sys.argv = ["ipython", "--pylab"] 
    176             from IPython import start_ipython 
    177             sys.exit(start_ipython()) 
     184    setup_logging() 
     185    setup_wx() 
     186    setup_mpl() 
     187    SasView() 
     188 
     189 
     190def run_cli(): 
     191    setup_mpl() 
     192    if len(sys.argv) == 1: 
     193        # Run sasview as an interactive python interpreter 
     194        sys.argv = ["ipython", "--pylab"] 
     195        from IPython import start_ipython 
     196        sys.exit(start_ipython()) 
     197    else: 
     198        # Run sasview as a python script interpreter 
    178199        thing_to_run = sys.argv[1] 
    179200        sys.argv = sys.argv[1:] 
     
    183204        else: 
    184205            runpy.run_module(thing_to_run, run_name="__main__") 
    185     else: 
    186         SasView() 
    187206 
    188207if __name__ == "__main__": 
    189     run() 
    190  
     208    run_gui() 
     209 
Note: See TracChangeset for help on using the changeset viewer.