- Timestamp:
- Apr 11, 2017 6:08:57 AM (8 years ago)
- 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b854587
- Parents:
- 09983d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
run.py
r7fb59b2 rf36e01f 1 1 # -*- coding: utf-8 -*- 2 2 #!/usr/bin/env python 3 3 4 """ 4 5 Run sasview in place. This allows sasview to use the python … … 16 17 17 18 import imp 18 import logging19 import logging.config20 19 import os 21 20 import sys … … 38 37 sys.path.insert(0, path) 39 38 39 40 40 @contextmanager 41 41 def cd(path): … … 48 48 os.chdir(old_dir) 49 49 50 50 51 def import_package(modname, path): 51 52 """Import a package into a particular point in the python namespace""" 52 mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py')))53 mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py'))) 53 54 sys.modules[modname] = mod 54 55 mod.__path__ = [abspath(path)] 55 56 return mod 57 56 58 57 59 def import_dll(modname, build_path): … … 60 62 ext = sysconfig.get_config_var('SO') 61 63 # build_path comes from context 62 path = joinpath(build_path, *modname.split('.')) +ext63 # print "importing", modname, "from", path64 path = joinpath(build_path, *modname.split('.')) + ext 65 # print "importing", modname, "from", path 64 66 return imp.load_dynamic(modname, path) 67 65 68 66 69 def prepare(): … … 74 77 from distutils.util import get_platform 75 78 root = abspath(dirname(__file__)) 76 platform = '%s-%s' %(get_platform(),sys.version[:3])77 build_path = joinpath(root, 'build', 'lib.'+platform)79 platform = '%s-%s' % (get_platform(), sys.version[:3]) 80 build_path = joinpath(root, 'build', 'lib.' + platform) 78 81 79 82 # Notify the help menu that the Sphinx documentation is in a different … … 86 89 #if not os.path.exists(mplconfig): os.mkdir(mplconfig) 87 90 #import matplotlib 88 # matplotlib.use('Agg')89 # print matplotlib.__file__91 # matplotlib.use('Agg') 92 # print matplotlib.__file__ 90 93 #import pylab; pylab.hold(False) 91 94 # add periodictable to the path 92 try: import periodictable 93 except: addpath(joinpath(root, '..','periodictable')) 95 try: 96 import periodictable 97 except: 98 addpath(joinpath(root, '..', 'periodictable')) 94 99 95 try: import bumps 96 except: addpath(joinpath(root, '..','bumps')) 100 try: 101 import bumps 102 except: 103 addpath(joinpath(root, '..', 'bumps')) 97 104 98 105 # select wx version … … 114 121 # be better to just store the package in src/sas/sasview. 115 122 import sas 116 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview'))123 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview')) 117 124 118 125 # The sas.models package Compiled Model files should be pulled in from the build directory even though … … 123 130 import sas.sascalc.pr 124 131 sas.sascalc.pr.core = import_package('sas.sascalc.pr.core', 125 joinpath(build_path, 'sas', 'sascalc', 'pr', 'core'))132 joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 126 133 127 134 # Compiled modules need to be pulled from the build directory. … … 129 136 import sas.sascalc.file_converter 130 137 sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core', 131 joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))138 joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core')) 132 139 133 140 # Compiled modules need to be pulled from the build directory. … … 135 142 import sas.sascalc.calculator 136 143 sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core', 137 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core'))144 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 138 145 139 146 sys.path.append(build_path) 140 147 141 #print "\n".join(sys.path) 148 # print "\n".join(sys.path) 149 142 150 143 151 if __name__ == "__main__": 144 # Need to add absolute path before actual prepare call,145 # so logging can be done during initialization process too152 # Need to add absolute path before actual prepare call, 153 # so logging can be done during initialization process too 146 154 root = abspath(dirname(__file__)) 147 155 addpath(joinpath(root, 'sasview'))
Note: See TracChangeset
for help on using the changeset viewer.