source: MPbranch/GSASIIpath.py @ 1113

Last change on this file since 1113 was 517, checked in by toby, 13 years ago

make sure that texture is initialized for multiprocessing

  • Property svn:keywords set to Date Author Revision URL Id
File size: 1.9 KB
Line 
1''' determine a binary path for the pyd files based on the host OS and the python version,
2path is relative to location of the script that is called as well as this file
3this must be imported before anything that imports any .pyd/.so file for GSASII
4
5also determine if GSAS-II is being run interactively'''
6
7import os.path as ospath
8import sys
9import platform
10
11# Find the name of the main routine and if we are running interactively (true if GSASII.py)
12import __main__
13GSAS2interactive = False
14try:
15    if ospath.split(__main__.__file__)[1].lower() == "gsasii.py":
16        GSAS2interactive = True
17except:
18   pass
19
20# define the path to where GSAS-II source files are found from the location of
21# the current file
22path2GSAS2 = ospath.dirname(ospath.realpath(__file__))
23
24bindir = None
25if sys.platform == "win32":
26    if platform.architecture()[0] == '64bit':
27        bindir = 'binwin64-%d.%d' % sys.version_info[0:2]
28    else:
29        bindir = 'binwin%d.%d' % sys.version_info[0:2]
30elif sys.platform == "darwin":
31    bindir = 'binmac%d.%d' % sys.version_info[0:2]
32elif sys.platform == "linux2":
33    if platform.architecture()[0] == '64bit':
34        bindir = 'binlinux64-%d.%d' % sys.version_info[0:2]
35    else:
36        bindir = 'binlinux%d.%d' % sys.version_info[0:2]
37for loc in sys.path[0],path2GSAS2:
38    if bindir:
39        if ospath.exists(ospath.join(loc,bindir)) and ospath.join(loc,bindir) not in sys.path: 
40            sys.path.insert(0,ospath.join(loc,bindir))
41        # is there a bin directory? (created by a local compile), if so put
42        # that at the top of the path
43    if ospath.exists(ospath.join(loc,'bin')):
44        bindir = 'bin'
45        if ospath.join(loc,'bin') not in sys.path: 
46            sys.path.insert(0,ospath.join(loc,bindir))
47if bindir == None:
48    print "Warning GSAS-II binary libraries not found, some sections of code will not function"
Note: See TracBrowser for help on using the repository browser.