- Timestamp:
- May 26, 2017 7:41:44 AM (7 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
run.py
r83eb5208 rc416a17 1 # -*- coding: utf-8 -*- 1 2 #!/usr/bin/env python 3 2 4 """ 3 5 Run sasview in place. This allows sasview to use the python … … 14 16 """ 15 17 18 import imp 16 19 import os 17 20 import sys 18 import imp19 21 from contextlib import contextmanager 20 from os.path import abspath, dirname, join as joinpath 22 from os.path import join as joinpath 23 from os.path import abspath, dirname 21 24 22 25 … … 34 37 sys.path.insert(0, path) 35 38 39 36 40 @contextmanager 37 41 def cd(path): … … 44 48 os.chdir(old_dir) 45 49 50 46 51 def import_package(modname, path): 47 52 """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'))) 49 55 sys.modules[modname] = mod 50 56 mod.__path__ = [abspath(path)] 51 57 return mod 58 52 59 53 60 def import_dll(modname, build_path): … … 56 63 ext = sysconfig.get_config_var('SO') 57 64 # 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 59 67 return imp.load_dynamic(modname, path) 68 60 69 61 70 def prepare(): … … 69 78 from distutils.util import get_platform 70 79 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) 73 82 74 83 # Notify the help menu that the Sphinx documentation is in a different … … 76 85 os.environ['SASVIEW_DOC_PATH'] = joinpath(build_path, "doc") 77 86 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) 78 95 # 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')) 81 100 82 try: import bumps 83 except: addpath(joinpath(root, '..','bumps')) 101 try: 102 import bumps 103 except: 104 addpath(joinpath(root, '..', 'bumps')) 84 105 85 106 # Build project if the build directory does not already exist. … … 98 119 # be better to just store the package in src/sas/sasview. 99 120 import sas 100 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview'))121 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview')) 101 122 102 123 # Compiled modules need to be pulled from the build directory. … … 104 125 import sas.sascalc.pr 105 126 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')) 107 128 108 129 # Compiled modules need to be pulled from the build directory. … … 110 131 import sas.sascalc.file_converter 111 132 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')) 113 134 114 135 # Compiled modules need to be pulled from the build directory. … … 116 137 import sas.sascalc.calculator 117 138 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')) 119 140 120 141 sys.path.append(build_path) 121 142 122 143 if __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.") 123 152 prepare() 124 153 from sas.qtgui.MainWindow.MainWindow import run 125 154 run() 155 logger.debug("Ending SASVIEW in debug mode.")
Note: See TracChangeset
for help on using the changeset viewer.