Changeset 2952 for branch/2frame/GSASIIpath.py
- Timestamp:
- Jul 30, 2017 7:37:08 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/2frame/GSASIIpath.py
r2936 r2952 28 28 29 29 path2GSAS2 = os.path.dirname(os.path.realpath(__file__)) # location of this file; save before any changes in pwd 30 31 # convert version numbers as '1.2.3' to integers (1002) and back (to 1.2) 32 fmtver = lambda v: str(v//1000)+'.'+str(v%1000) 33 intver = lambda vs: sum([int(i) for i in vs.split('.')[0:2]]*np.array((1000,1))) 30 34 31 35 def GetConfigValue(key,default=None): … … 432 436 print ("Files installed at: "+loadpath) 433 437 return True 434 435 def DownloadG2Binaries(g2home,verbose=True): 436 '''Download GSAS-II binaries from appropriate section of the 437 GSAS-II svn repository based on the platform, numpy and Python 438 version 439 ''' 440 # convert version numbers as '1.2.3' to integers (1002) and back (to 1.2) 441 fmtver = lambda v: str(v//1000)+'.'+str(v%1000) 442 intver = lambda vs: sum([int(i) for i in vs.split('.')[0:2]]*np.array((1000,1))) 443 438 439 def GetBinaryPrefix(): 444 440 if sys.platform == "win32": 445 441 prefix = 'win' … … 456 452 bits = '32' 457 453 458 # format current python & numpy versions454 # format current python version 459 455 pyver = 'p{}.{}'.format(*sys.version_info[0:2]) 460 npver = 'n{}.{}'.format(*np.__version__.split('.')[0:2]) 456 457 items = [prefix,bits,pyver] 458 return '_'.join(items) 459 460 def DownloadG2Binaries(g2home,verbose=True): 461 '''Download GSAS-II binaries from appropriate section of the 462 GSAS-II svn repository based on the platform, numpy and Python 463 version 464 ''' 465 bindir = GetBinaryPrefix() 466 #npver = 'n{}.{}'.format(*np.__version__.split('.')[0:2]) 461 467 inpver = intver(np.__version__) 462 463 items = [prefix,bits,pyver]464 bindir = '_'.join(items)465 466 468 svn = whichsvn() 467 469 if not svn: … … 669 671 global BinaryPathLoaded 670 672 if BinaryPathLoaded: return 671 BinaryPathLoaded = True673 inpver = intver(np.__version__) 672 674 binpath = None 675 binprfx = GetBinaryPrefix() 673 676 for loc in os.path.abspath(sys.path[0]),os.path.abspath(os.path.split(__file__)[0]): 674 # Look at bin directory (created by a local compile) before standard dist 675 # that at the top of the path 676 for d in 'bin','bindist': 677 if not d: continue 678 fpth = os.path.join(loc,d) 677 # Look at bin directory (created by a local compile) before looking for standard dist files 678 searchpathlist = [os.path.join(loc,'bin')] 679 # also look for matching binary dist in loc/AllBinaries 680 versions = {} 681 for d in glob.glob(os.path.join(loc,'AllBinaries',binprfx+'*')): 682 v = intver(d.rstrip('/').split('_')[3].lstrip('n')) 683 versions[v] = d 684 searchpathlist = [os.path.join(loc,'bin')] 685 vmin = None 686 vmax = None 687 for v in sorted(versions.keys()): 688 if v <= inpver: 689 vmin = v 690 elif v > inpver: 691 vmax = v 692 break 693 if vmin in versions: 694 searchpathlist.append(versions[vmin]) 695 if vmax in versions: 696 searchpathlist.append(versions[vmax]) 697 searchpathlist.append(os.path.join(loc,'bindist')) 698 for fpth in searchpathlist: 679 699 if TestSPG(fpth): 680 700 binpath = fpth … … 684 704 sys.path.insert(0,binpath) 685 705 print('GSAS-II binary directory: {}'.format(binpath)) 706 BinaryPathLoaded = True 686 707 else: # try loading them 687 708 print('Attempting to download GSAS-II binary files...') … … 693 714 print('GSAS-II binary directory: {}'.format(binpath)) 694 715 sys.path.insert(0,binpath) 716 BinaryPathLoaded = True 695 717 # this must be imported before anything that imports any .pyd/.so file for GSASII 696 718 else: … … 699 721 # patch: use old location based on the host OS and the python version, 700 722 # path is relative to location of the script that is called as well as this file 723 BinaryPathLoaded = True 701 724 bindir = None 702 725 if sys.platform == "win32":
Note: See TracChangeset
for help on using the changeset viewer.