Changeset 2366fb2 in sasview for src/sas/qtgui/MainWindow.py


Ignore:
Timestamp:
Oct 6, 2016 3:49:17 PM (8 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:
fca1f50
Parents:
630155bd
git-author:
Piotr Rozyczko <rozyczko@…> (10/06/16 15:48:06)
git-committer:
Piotr Rozyczko <rozyczko@…> (10/06/16 15:49:17)
Message:

Added a temporary solution for running the new GUI in place.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow.py

    • Property mode changed from 100755 to 100644
    rf51ed67 r2366fb2  
    99import SasviewLogger 
    1010 
     11def updatePaths(): 
     12    # Update paths 
     13    # TEMPORARY KLUDGE TO ALLOW INSTALL-LESS RUNS 
     14    # THIS WILL GO AWAY ONCE MERGED 
     15    ####################################################################### 
     16    import imp 
     17    import os 
     18    import sys 
     19    def addpath(path): 
     20        """ 
     21        Add a directory to the python path environment, and to the PYTHONPATH 
     22        environment variable for subprocesses. 
     23        """ 
     24        path = os.path.abspath(path) 
     25        if 'PYTHONPATH' in os.environ: 
     26            PYTHONPATH = path + os.pathsep + os.environ['PYTHONPATH'] 
     27        else: 
     28            PYTHONPATH = path 
     29        os.environ['PYTHONPATH'] = PYTHONPATH 
     30        sys.path.insert(0, path) 
     31 
     32    def import_package(modname, path): 
     33        """Import a package into a particular point in the python namespace""" 
     34        mod = imp.load_source(modname, os.path.abspath(os.path.join(path,'__init__.py'))) 
     35        sys.modules[modname] = mod 
     36        mod.__path__ = [os.path.abspath(path)] 
     37        return mod 
     38 
     39    root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) 
     40    addpath(os.path.join(root, 'src')) 
     41    #addpath(os.path.join(root, '../sasmodels/')) 
     42    import sas 
     43    from distutils.util import get_platform 
     44    sas.sasview = import_package('sas.sasview', os.path.join(root,'sasview')) 
     45    platform = '%s-%s'%(get_platform(),sys.version[:3]) 
     46    build_path = os.path.join(root, 'build','lib.'+platform) 
     47    sys.path.append(build_path) 
     48    ####################################################################### 
     49 
    1150class MainSasViewWindow(QtGui.QMainWindow, Ui_MainWindow): 
    1251    # Main window of the application 
     
    1857        self.workspace = QtGui.QWorkspace(self) 
    1958        self.setCentralWidget(self.workspace) 
     59 
     60        updatePaths() 
    2061 
    2162        # Create the gui manager 
Note: See TracChangeset for help on using the changeset viewer.