Changeset 2a8bd705 in sasview


Ignore:
Timestamp:
Jul 25, 2017 4:36:48 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
b00414d
Parents:
6ff2eb3
Message:

Changes to allow pyinstaller builds

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • run.py

    • Property mode changed from 100644 to 100755
    rc416a17 r2a8bd705  
    2121from contextlib import contextmanager 
    2222from os.path import join as joinpath 
    23 from os.path import abspath, dirname 
     23from os.path import abspath, dirname, realpath 
    2424 
    2525 
     
    6464    # build_path comes from context 
    6565    path = joinpath(build_path, *modname.split('.')) + ext 
    66     # print "importing", modname, "from", path 
    6766    return imp.load_dynamic(modname, path) 
    6867 
     
    7776    # find the directories for the source and build 
    7877    from distutils.util import get_platform 
    79     root = abspath(dirname(__file__)) 
     78    root = abspath(dirname(sys.argv[0])) 
     79 
    8080    platform = '%s-%s' % (get_platform(), sys.version[:3]) 
    8181    build_path = joinpath(root, 'build', 'lib.' + platform) 
     
    144144    # Need to add absolute path before actual prepare call, 
    145145    # so logging can be done during initialization process too 
    146     root = abspath(dirname(__file__)) 
     146    root = abspath(dirname(realpath(sys.argv[0]))) 
    147147    addpath(joinpath(root, 'sasview')) 
    148148    from logger_config import SetupLogger 
  • sasview/local_config.py

    rc416a17 r2a8bd705  
    114114#DEFAULT_STYLE = GUIFRAME.MULTIPLE_APPLICATIONS|GUIFRAME.MANAGER_ON\ 
    115115#                    |GUIFRAME.CALCULATOR_ON|GUIFRAME.TOOLBAR_ON 
     116DEFAULT_STYLE = 64 
     117 
    116118SPLASH_SCREEN_WIDTH = 512 
    117119SPLASH_SCREEN_HEIGHT = 366 
  • sasview/sasview.py

    rf36e01f r2a8bd705  
    1212# copyright 2009, University of Tennessee 
    1313################################################################################ 
    14 import os 
    15 import os.path 
    1614import sys 
    17 import traceback 
    1815 
    1916from sas.sasview.logger_config import SetupLogger 
     
    2724logger.info("Python: %s" % sys.version) 
    2825 
    29 # Allow the dynamic selection of wxPython via an environment variable, when devs 
    30 # who have multiple versions of the module installed want to pick between them. 
    31 # This variable does not have to be set of course, and through normal usage will 
    32 # probably not be, but this can make things a little easier when upgrading to a 
    33 # new version of wx. 
    34 WX_ENV_VAR = "SASVIEW_WX_VERSION" 
    35 if WX_ENV_VAR in os.environ: 
    36     logger.info("You have set the %s environment variable to %s." % \ 
    37                  (WX_ENV_VAR, os.environ[WX_ENV_VAR])) 
    38     import wxversion 
    39     if wxversion.checkInstalled(os.environ[WX_ENV_VAR]): 
    40         logger.info("Version %s of wxPython is installed, so using that version." % os.environ[WX_ENV_VAR]) 
    41         wxversion.select(os.environ[WX_ENV_VAR]) 
    42     else: 
    43         logger.error("Version %s of wxPython is not installed, so using default version." % os.environ[WX_ENV_VAR]) 
    44 else: 
    45     logger.info("You have not set the %s environment variable, so using default version of wxPython." % WX_ENV_VAR) 
    4626 
    47 import wx 
    48  
    49 try: 
    50     logger.info("Wx version: %s" % wx.__version__) 
    51 except: 
    52     logger.error("Wx version: error reading version") 
    53  
    54 import wxcruft 
    55 wxcruft.call_later_fix() 
    56 # wxcruft.trace_new_id() 
    57  
    58 # Always use private .matplotlib setup to avoid conflicts with other 
    59 # uses of matplotlib 
    60 # Have to check if .sasview exists first 
    61 sasdir = os.path.join(os.path.expanduser("~"),'.sasview') 
    62 if not os.path.exists(sasdir): 
    63     os.mkdir(sasdir) 
    64 mplconfigdir = os.path.join(os.path.expanduser("~"),'.sasview','.matplotlib') 
    65 if not os.path.exists(mplconfigdir): 
    66     os.mkdir(mplconfigdir) 
    67 os.environ['MPLCONFIGDIR'] = mplconfigdir 
    6827reload(sys) 
    6928sys.setdefaultencoding("iso-8859-1") 
    70 from sas.sasgui.guiframe import gui_manager 
    71 from sas.sasgui.guiframe.gui_style import GUIFRAME 
    72 from welcome_panel import WelcomePanel 
    7329 
    7430PLUGIN_MODEL_DIR = 'plugin_models' 
    7531APP_NAME = 'SasView' 
    7632 
    77 from matplotlib import backend_bases 
    78 backend_bases.FigureCanvasBase.filetypes.pop('pgf', None) 
    79  
    80 class SasView(): 
    81     """ 
    82     Main class for running the SasView application 
    83     """ 
    84     def __init__(self): 
    85         """ 
    86         """ 
    87         # from gui_manager import ViewApp 
    88         self.gui = gui_manager.SasViewApp(0) 
    89         # Set the application manager for the GUI 
    90         self.gui.set_manager(self) 
    91         # Add perspectives to the basic application 
    92         # Additional perspectives can still be loaded 
    93         # dynamically 
    94         # Note: py2exe can't find dynamically loaded 
    95         # modules. We load the fitting module here 
    96         # to ensure a complete Windows executable build. 
    97  
    98         # Fitting perspective 
    99         try: 
    100             import sas.sasgui.perspectives.fitting as module 
    101             fitting_plug = module.Plugin() 
    102             self.gui.add_perspective(fitting_plug) 
    103         except Exception: 
    104             logger.error("%s: could not find Fitting plug-in module"% APP_NAME) 
    105             logger.error(traceback.format_exc()) 
    106  
    107         # P(r) perspective 
    108         try: 
    109             import sas.sasgui.perspectives.pr as module 
    110             pr_plug = module.Plugin() 
    111             self.gui.add_perspective(pr_plug) 
    112         except: 
    113             logger.error("%s: could not find P(r) plug-in module"% APP_NAME) 
    114             logger.error(traceback.format_exc()) 
    115  
    116         # Invariant perspective 
    117         try: 
    118             import sas.sasgui.perspectives.invariant as module 
    119             invariant_plug = module.Plugin() 
    120             self.gui.add_perspective(invariant_plug) 
    121         except Exception as e : 
    122             logger.error("%s: could not find Invariant plug-in module"% \ 
    123                           APP_NAME) 
    124             logger.error(traceback.format_exc()) 
    125  
    126         # Corfunc perspective 
    127         try: 
    128             import sas.sasgui.perspectives.corfunc as module 
    129             corfunc_plug = module.Plugin() 
    130             self.gui.add_perspective(corfunc_plug) 
    131         except: 
    132             logger.error("Unable to load corfunc module") 
    133  
    134         # Calculator perspective 
    135         try: 
    136             import sas.sasgui.perspectives.calculator as module 
    137             calculator_plug = module.Plugin() 
    138             self.gui.add_perspective(calculator_plug) 
    139         except: 
    140             logger.error("%s: could not find Calculator plug-in module"% \ 
    141                                                         APP_NAME) 
    142             logger.error(traceback.format_exc()) 
    143  
    144         # File converter tool 
    145         try: 
    146             import sas.sasgui.perspectives.file_converter as module 
    147             converter_plug = module.Plugin() 
    148             self.gui.add_perspective(converter_plug) 
    149         except: 
    150             logger.error("%s: could not find File Converter plug-in module"% \ 
    151                                                         APP_NAME) 
    152             logger.error(traceback.format_exc()) 
    153  
    154         # Add welcome page 
    155         self.gui.set_welcome_panel(WelcomePanel) 
    156  
    157         # Build the GUI 
    158         self.gui.build_gui() 
    159         # delete unused model folder 
    160         self.gui.clean_plugin_models(PLUGIN_MODEL_DIR) 
    161         # Start the main loop 
    162         self.gui.MainLoop() 
    163  
    164  
    165 def run(): 
     33def runSasView(): 
    16634    """ 
    16735    __main__ method for loading and running SasView 
     
    16937    from multiprocessing import freeze_support 
    17038    freeze_support() 
    171     if len(sys.argv) > 1: 
    172         ## Run sasview as an interactive python interpreter 
    173         # if sys.argv[1] == "-i": 
    174         #    sys.argv = ["ipython", "--pylab"] 
    175         #    from IPython import start_ipython 
    176         #    sys.exit(start_ipython()) 
    177         thing_to_run = sys.argv[1] 
    178         sys.argv = sys.argv[1:] 
    179         import runpy 
    180         if os.path.exists(thing_to_run): 
    181             runpy.run_path(thing_to_run, run_name="__main__") 
    182         else: 
    183             runpy.run_module(thing_to_run, run_name="__main__") 
    184     else: 
    185         SasView() 
     39    from sas.qtgui.MainWindow.MainWindow import run 
     40    run() 
    18641 
    18742 
    18843if __name__ == "__main__": 
    189     run() 
     44    runSasView() 
  • sasview/sasview.spec

    • Property mode changed from 100755 to 100644
    re42c8e9d r2a8bd705  
    5151datas.append(('welcome_panel.py','.')) 
    5252 
     53datas.append((os.path.join(PYTHON_LOC,'Lib','SocketServer.py'),'.')) 
     54 
    5355# TODO 
    5456# NEED BETTER WAY TO DEAL WITH THESE RELATIVE PATHS 
    5557datas.append((os.path.join('..','..','sasmodels','sasmodels'),'sasmodels')) 
    5658datas.append((os.path.join('..','src','sas','sasgui','perspectives','fitting','plugin_models'),'plugin_models')) 
    57  
    58 # precompile sas models into the sasview build path; doesn't matter too much 
    59 # where it is so long as it is a place that will get cleaned up afterwards. 
    60 import sasmodels.core 
    61 dll_path = 'compiled_models' 
    62 if not (os.path.exists(dll_path)): 
    63     os.mkdir(dll_path) 
    64 dll_path2 = os.path.join(dll_path, dll_path) 
    65 if not (os.path.exists(dll_path2)): 
    66     os.mkdir(dll_path2) 
    67  
    68 compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double') 
    69  
    70 # include the compiled models as data; coordinate the target path for the 
    71 # data with installer_generator.py 
    72 datas.append((os.path.join('compiled_models','compiled_models'),'compiled_models')) 
    7359 
    7460# These depend on whether we have MKL or Atlas numpy 
     
    114100# Spelled out to enable easier editing 
    115101excludes = [] 
    116 excludes.append('libzmq') 
    117 excludes.append('IPython') 
    118 excludes.append('PyQt4') 
    119 excludes.append('PySide') 
    120 excludes.append('Qt4') 
    121 excludes.append('Tkinter') 
    122 excludes.append('tk') 
    123 excludes.append('tcl') 
    124 # Seems we cannot build on Linux without bundling sip 
    125 if not platform.system() == 'Linux': 
    126     excludes.append('sip') 
    127 excludes.append('sympy') 
    128 excludes.append('pytz') 
    129 excludes.append('sklearn') 
    130 excludes.append('zmq') 
    131102 
    132103# Need to explicitly exclude sasmodels here!! 
     
    138109 'sasmodels.core', 
    139110 'pyopencl', 
    140  'tinycc' 
     111 'tinycc', 
     112 'SocketServer' 
    141113] 
    142114 
  • src/sas/qtgui/MainWindow/MainWindow.py

    rcd2cc745 r2a8bd705  
    4848    splash.show() 
    4949 
     50    # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError 
     51    import sys 
     52    if 'twisted.internet.reactor' in sys.modules: 
     53        del sys.modules['twisted.internet.reactor'] 
     54 
    5055    # DO NOT move the following import to the top! 
    5156    # (unless you know what you're doing) 
Note: See TracChangeset for help on using the changeset viewer.