Changeset c416a17 in sasview for run.py


Ignore:
Timestamp:
May 26, 2017 7:41:44 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:
c1e380e
Parents:
6964d44 (diff), 7132e49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ESS_GUI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r83eb5208 rc416a17  
     1# -*- coding: utf-8 -*- 
    12#!/usr/bin/env python 
     3 
    24""" 
    35Run sasview in place.  This allows sasview to use the python 
     
    1416""" 
    1517 
     18import imp 
    1619import os 
    1720import sys 
    18 import imp 
    1921from contextlib import contextmanager 
    20 from os.path import abspath, dirname, join as joinpath 
     22from os.path import join as joinpath 
     23from os.path import abspath, dirname 
    2124 
    2225 
     
    3437    sys.path.insert(0, path) 
    3538 
     39 
    3640@contextmanager 
    3741def cd(path): 
     
    4448    os.chdir(old_dir) 
    4549 
     50 
    4651def import_package(modname, path): 
    4752    """Import a package into a particular point in the python namespace""" 
    48     mod = imp.load_source(modname, abspath(joinpath(path,'__init__.py'))) 
     53    #logger.debug("Dynamicly importing: %s", path) 
     54    mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py'))) 
    4955    sys.modules[modname] = mod 
    5056    mod.__path__ = [abspath(path)] 
    5157    return mod 
     58 
    5259 
    5360def import_dll(modname, build_path): 
     
    5663    ext = sysconfig.get_config_var('SO') 
    5764    # build_path comes from context 
    58     path = joinpath(build_path, *modname.split('.'))+ext 
     65    path = joinpath(build_path, *modname.split('.')) + ext 
     66    # print "importing", modname, "from", path 
    5967    return imp.load_dynamic(modname, path) 
     68 
    6069 
    6170def prepare(): 
     
    6978    from distutils.util import get_platform 
    7079    root = abspath(dirname(__file__)) 
    71     platform = '%s-%s'%(get_platform(),sys.version[:3]) 
    72     build_path = joinpath(root, 'build','lib.'+platform) 
     80    platform = '%s-%s' % (get_platform(), sys.version[:3]) 
     81    build_path = joinpath(root, 'build', 'lib.' + platform) 
    7382 
    7483    # Notify the help menu that the Sphinx documentation is in a different 
     
    7685    os.environ['SASVIEW_DOC_PATH'] = joinpath(build_path, "doc") 
    7786 
     87    # Make sure that we have a private version of mplconfig 
     88    #mplconfig = joinpath(abspath(dirname(__file__)), '.mplconfig') 
     89    #os.environ['MPLCONFIGDIR'] = mplconfig 
     90    #if not os.path.exists(mplconfig): os.mkdir(mplconfig) 
     91    #import matplotlib 
     92    # matplotlib.use('Agg') 
     93    # print matplotlib.__file__ 
     94    #import pylab; pylab.hold(False) 
    7895    # add periodictable to the path 
    79     try: import periodictable 
    80     except: addpath(joinpath(root, '..','periodictable')) 
     96    try: 
     97        import periodictable 
     98    except: 
     99        addpath(joinpath(root, '..', 'periodictable')) 
    81100 
    82     try: import bumps 
    83     except: addpath(joinpath(root, '..','bumps')) 
     101    try: 
     102        import bumps 
     103    except: 
     104        addpath(joinpath(root, '..', 'bumps')) 
    84105 
    85106    # Build project if the build directory does not already exist. 
     
    98119    # be better to just store the package in src/sas/sasview. 
    99120    import sas 
    100     sas.sasview = import_package('sas.sasview', joinpath(root,'sasview')) 
     121    sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview')) 
    101122 
    102123    # Compiled modules need to be pulled from the build directory. 
     
    104125    import sas.sascalc.pr 
    105126    sas.sascalc.pr.core = import_package('sas.sascalc.pr.core', 
    106                                   joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 
     127                                         joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 
    107128 
    108129    # Compiled modules need to be pulled from the build directory. 
     
    110131    import sas.sascalc.file_converter 
    111132    sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core', 
    112                                   joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))                     
     133                                                     joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core')) 
    113134 
    114135    # Compiled modules need to be pulled from the build directory. 
     
    116137    import sas.sascalc.calculator 
    117138    sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core', 
    118                                   joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 
     139                                                 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 
    119140 
    120141    sys.path.append(build_path) 
    121142 
    122143if __name__ == "__main__": 
     144    # Need to add absolute path before actual prepare call, 
     145    # so logging can be done during initialization process too 
     146    root = abspath(dirname(__file__)) 
     147    addpath(joinpath(root, 'sasview')) 
     148    from logger_config import SetupLogger 
     149    logger = SetupLogger(__name__).config_development() 
     150 
     151    logger.debug("Starting SASVIEW in debug mode.") 
    123152    prepare() 
    124153    from sas.qtgui.MainWindow.MainWindow import run 
    125154    run() 
     155    logger.debug("Ending SASVIEW in debug mode.") 
Note: See TracChangeset for help on using the changeset viewer.