[65] | 1 | # determine a binary path for the pyd files based on the host OS and the python version, |
---|
[170] | 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 |
---|
[65] | 4 | import os.path as ospath |
---|
| 5 | import sys |
---|
[181] | 6 | import platform |
---|
[93] | 7 | bindir = None |
---|
[65] | 8 | if sys.platform == "win32": |
---|
[181] | 9 | if platform.architecture()[0] == '64bit': |
---|
| 10 | bindir = 'binwin64-%d.%d' % sys.version_info[0:2] |
---|
| 11 | else: |
---|
| 12 | bindir = 'binwin%d.%d' % sys.version_info[0:2] |
---|
[65] | 13 | elif sys.platform == "darwin": |
---|
| 14 | bindir = 'binmac%d.%d' % sys.version_info[0:2] |
---|
[93] | 15 | elif sys.platform == "linux2": |
---|
| 16 | bindir = 'binlinux%d.%d' % sys.version_info[0:2] |
---|
[170] | 17 | for loc in sys.path[0],ospath.split(__file__)[0]: |
---|
| 18 | if bindir: |
---|
| 19 | if ospath.exists(ospath.join(loc,bindir)) and ospath.join(loc,bindir) not in sys.path: |
---|
| 20 | sys.path.insert(0,ospath.join(loc,bindir)) |
---|
| 21 | # is there a bin directory? (created by a local compile), if so put |
---|
| 22 | # that at the top of the path |
---|
| 23 | if ospath.exists(ospath.join(loc,'bin')): |
---|
| 24 | bindir = 'bin' |
---|
| 25 | if ospath.join(loc,'bin') not in sys.path: |
---|
| 26 | sys.path.insert(0,ospath.join(loc,bindir)) |
---|
[93] | 27 | if bindir == None: |
---|
| 28 | print "Warning GSAS-II binary libraries not found, some sections of code will not function" |
---|