source: sasview/src/sas/qtgui/path_prepare.py @ c416a17

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since c416a17 was ded2ce3, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

missing module importer added

  • Property mode set to 100755
File size: 1.2 KB
Line 
1"""
2Prepare python system path to point to right locations
3"""
4import imp
5import os
6import sys
7def addpath(path):
8    """
9    Add a directory to the python path environment, and to the PYTHONPATH
10    environment variable for subprocesses.
11    """
12    path = os.path.abspath(path)
13    if 'PYTHONPATH' in os.environ:
14        PYTHONPATH = path + os.pathsep + os.environ['PYTHONPATH']
15    else:
16        PYTHONPATH = path
17    os.environ['PYTHONPATH'] = PYTHONPATH
18    sys.path.insert(0, path)
19
20def import_package(modname, path):
21    """Import a package into a particular point in the python namespace"""
22    mod = imp.load_source(modname, os.path.abspath(os.path.join(path,'__init__.py')))
23    sys.modules[modname] = mod
24    mod.__path__ = [os.path.abspath(path)]
25    return mod
26
27root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
28addpath(os.path.join(root, 'src'))
29#addpath(os.path.join(root, '../sasmodels/'))
30import sas
31from distutils.util import get_platform
32sas.sasview = import_package('sas.sasview', os.path.join(root,'sasview'))
33platform = '%s-%s'%(get_platform(),sys.version[:3])
34build_path = os.path.join(root, 'build','lib.'+platform)
35sys.path.append(build_path)
Note: See TracBrowser for help on using the repository browser.