1 | ''' determine a binary path for the pyd files based on the host OS and the python version, |
---|
2 | path is relative to location of the script that is called as well as this file |
---|
3 | this must be imported before anything that imports any .pyd/.so file for GSASII |
---|
4 | |
---|
5 | also determine if GSAS-II is being run interactively''' |
---|
6 | |
---|
7 | import os.path as ospath |
---|
8 | import sys |
---|
9 | import platform |
---|
10 | |
---|
11 | # Find the name of the main routine and if we are running interactively (true if GSASII.py) |
---|
12 | import __main__ |
---|
13 | GSAS2interactive = False |
---|
14 | try: |
---|
15 | if ospath.split(__main__.__file__)[1].lower() == "gsasii.py": |
---|
16 | GSAS2interactive = True |
---|
17 | except: |
---|
18 | pass |
---|
19 | |
---|
20 | # define the path to where GSAS-II source files are found from the location of |
---|
21 | # the current file |
---|
22 | path2GSAS2 = ospath.dirname(ospath.realpath(__file__)) |
---|
23 | |
---|
24 | bindir = None |
---|
25 | if 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] |
---|
30 | elif sys.platform == "darwin": |
---|
31 | bindir = 'binmac%d.%d' % sys.version_info[0:2] |
---|
32 | elif 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] |
---|
37 | for 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)) |
---|
47 | if bindir == None: |
---|
48 | print "Warning GSAS-II binary libraries not found, some sections of code will not function" |
---|